Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #############
- ## ALIASES ##
- #############
- # some more ls aliases
- alias ll='ls -alh'
- alias la='ls -A'
- alias l='ls -CFlh'
- # directory navigation aliases
- alias ..='cd ..'
- alias ...='cd ../..'
- alias ....='cd ../../..'
- alias .....='cd ../../../..'
- # apt aliases
- alias agi='sudo apt-get install'
- alias agu='sudo apt-get update'
- alias agg='sudo apt-get upgrade'
- alias agp='sudo apt-get purge'
- # chmod and permissions commands
- alias mx='chmod a+x'
- alias 000='chmod 000'
- alias 644='chmod 644'
- alias 755='chmod 755'
- alias df='df -Tha --total'
- alias du='du -ach | sort -h'
- alias ps='ps auxf'
- alias psg='ps aux | grep -v grep | grep -i -e VSZ -e'
- alias wget='wget -c'
- alias fhere='find . -name ' # find in current dir
- alias back='cd $OLDPWD'
- alias grep='grep --color=auto'
- alias reboot='sudo shutdown -r now'
- alias weather='curl -4 wttr.in'
- alias woo='fortune'
- alias top10='history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10'
- alias topn='history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n'
- ###############
- ## FUNCTIONS ##
- ###############
- # make dir and go to
- mcd () {
- mkdir -p $1
- cd $1
- }
- # copy and go to dir
- cpg (){
- if [ -d "$2" ];then
- cp $1 $2 && cd $2
- else
- cp $1 $2
- fi
- }
- #move and go to dir
- mvg (){
- if [ -d "$2" ];then
- mv $1 $2 && cd $2
- else
- mv $1 $2
- fi
- }
- # back up a file
- bu () { cp $1 ${1}-`date +%Y%m%d%H%M`.backup ; }
- # extract files
- function extract {
- if [ -z "$1" ]; then
- # display usage if no parameters given
- echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
- else
- if [ -f $1 ] ; then
- # NAME=${1%.*}
- # mkdir $NAME && cd $NAME
- case $1 in
- *.tar.bz2) tar xvjf ../$1 ;;
- *.tar.gz) tar xvzf ../$1 ;;
- *.tar.xz) tar xvJf ../$1 ;;
- *.lzma) unlzma ../$1 ;;
- *.bz2) bunzip2 ../$1 ;;
- *.rar) unrar x -ad ../$1 ;;
- *.gz) gunzip ../$1 ;;
- *.tar) tar xvf ../$1 ;;
- *.tbz2) tar xvjf ../$1 ;;
- *.tgz) tar xvzf ../$1 ;;
- *.zip) unzip ../$1 ;;
- *.Z) uncompress ../$1 ;;
- *.7z) 7z x ../$1 ;;
- *.xz) unxz ../$1 ;;
- *.exe) cabextract ../$1 ;;
- *) echo "extract: '$1' - unknown archive method" ;;
- esac
- else
- echo "$1 - file does not exist"
- fi
- fi
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement