Skip to content

Instantly share code, notes, and snippets.

@sssgun
Created April 5, 2018 03:17
Show Gist options
  • Save sssgun/7b0594b6f6df48b5b4fed0e09797ff55 to your computer and use it in GitHub Desktop.
Save sssgun/7b0594b6f6df48b5b4fed0e09797ff55 to your computer and use it in GitHub Desktop.

Revisions

  1. sssgun created this gist Apr 5, 2018.
    64 changes: 64 additions & 0 deletions .bashrc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,64 @@
    # SET Operations (by ssgun)
    ## extract file
    extract () {
    if [ -f $1 ] ; then
    case $1 in
    *.tar.bz2) tar xvjf $1 && cd $(basename "$1" .tar.bz2) ;;
    *.tar.gz) tar xvzf $1 && cd $(basename "$1" .tar.gz) ;;
    *.tar.xz) tar Jxvf $1 && cd $(basename "$1" .tar.xz) ;;
    *.bz2) bunzip2 $1 && cd $(basename "$1" /bz2) ;;
    *.rar) unrar x $1 && cd $(basename "$1" .rar) ;;
    *.gz) gunzip $1 && cd $(basename "$1" .gz) ;;
    *.tar) tar xvf $1 && cd $(basename "$1" .tar) ;;
    *.tbz2) tar xvjf $1 && cd $(basename "$1" .tbz2) ;;
    *.tgz) tar xvzf $1 && cd $(basename "$1" .tgz) ;;
    *.zip) unzip $1 && cd $(basename "$1" .zip) ;;
    *.Z) uncompress $1 && cd $(basename "$1" .Z) ;;
    *.7z) 7z x $1 && cd $(basename "$1" .7z) ;;
    *) echo "don't know how to extract '$1'..." ;;
    esac
    else
    echo "'$1' is not a valid file!"
    fi
    }

    ## grep
    alias grep='grep --color=auto'
    alias egrep='egrep --color=auto'

    function legrep {
    egrep --color=yes "$@" | less -R
    }

    function sgrep {
    egrep --color=yes --exclude-dir=.git "$@" | less -R
    }

    function fgrep {
    find $2 -name "*.c" | xargs grep --color=yes --exclude-dir=.git "$1";
    }

    alias mytty='gettty'

    function gettty {
    ps ax | grep $$ | awk '{ print $2 }'
    }

    function fvi {
    vi $(find . -name "$@")
    }

    ## ctags

    ## make
    alias mc='make clean && make -j4 && make install -j4'
    alias mi='make -j4 && make install -j4'

    ## git
    function sgc {
    git clone user.name="gun.song" -c user.email="[email protected]" $1 $2
    }

    function sgcb {
    git clone -b $1 -c user.name="gun.song" -c user.email="[email protected]" $2 $3
    }