Advertisement
learnlinuxtv

Untitled

Jan 27th, 2019
3,528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.88 KB | None | 0 0
  1. # PS1 Prompt
  2. tty -s && export PS1="\[\033[38;5;35m\]\t [\[\033[38;5;33m\]\j\[\033[38;5;35m\]] [\h:\[$(tput sgr0)\]\[\033[38;5;33m\]\w\[$(tput setaf 3)\]]\n\\[\033[38;5;35m\]$ \[$(tput sgr0)\]"
  3.  
  4. # Env
  5. export TERM=xterm-256color
  6. export EDITOR=vim
  7.  
  8. # Don't add duplicate lines or lines beginning with a space to the history
  9. HISTCONTROL=ignoreboth
  10.  
  11. # Set history format to include timestamps
  12. HISTTIMEFORMAT="%Y-%m-%d %T "
  13.  
  14. # Correct simple errors while using cd
  15. shopt -s cdspell
  16.  
  17. # Add /home/$USER/bin to $PATH
  18. case :$PATH: in
  19.     *:/home/$USER/bin:*) ;;
  20.     *) PATH=/home/$USER/bin:$PATH ;;
  21. esac
  22.  
  23. # Add /home/$USER/.tmux/tmuxifier to $PATH
  24. case :$PATH: in
  25.     *:/home/$USER/.tmux/tmuxifier/bin:*) ;;
  26.     *) PATH=/home/$USER/.tmux/tmuxifier/bin:$PATH ;;
  27. esac
  28.  
  29. # Command aliases
  30. alias ..='cd ..'
  31. alias ...='cd ../../../'
  32. alias ....='cd ../../../../'
  33. alias back='cd $OLDPWD'
  34. alias c='clear'
  35. alias cd..='cd ..'
  36. alias cp='cp -iv'
  37. alias chmod="chmod -c"
  38. alias chmod="chmod -c"
  39. alias df="df -h --exclude=squashfs"
  40. alias diff='colordiff'
  41. alias egrep='egrep --colour=auto'
  42. alias e="vim -O "
  43. alias E="vim -o "
  44. alias extip='curl icanhazip.com'
  45. alias grep='grep --color=auto'
  46. alias l.='ls -lhFa --time-style=long-iso --color=auto'
  47. alias ll='ls'
  48. alias ls='ls -lhF --time-style=long-iso --color=auto'
  49. alias lsmount='mount |column -t'
  50. alias mkdir='mkdir -pv'
  51. alias ports='netstat -tulanp'
  52. alias h='history'
  53. alias j='jobs -l'
  54. alias mv='mv -iv'
  55. alias speedtest='curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -'
  56. alias ssha='eval $(ssh-agent) && ssh-add'
  57. alias svim='sudo vim'
  58. alias tn=' tmux new -s'
  59. alias vdestroy='vagrant destroy'
  60. alias vssh='vagrant ssh'
  61. alias vup='vagrant up'
  62. alias wget='wget -c'
  63.  
  64. ## get top process eating memory
  65. alias mem5='ps auxf | sort -nr -k 4 | head -5'
  66. alias mem10='ps auxf | sort -nr -k 4 | head -10'
  67.  
  68. ## get top process eating cpu ##
  69. alias cpu5='ps auxf | sort -nr -k 3 | head -5'
  70. alias cpu10='ps auxf | sort -nr -k 3 | head -10'
  71.  
  72. ## List largest directories (aka "ducks")
  73. alias dir5='du -cksh * | sort -hr | head -n 5'
  74. alias dir10='du -cksh * | sort -hr | head -n 10'
  75.  
  76. # Safetynets
  77. # do not delete / or prompt if deleting more than 3 files at a time #
  78. alias rm='rm -I --preserve-root'
  79.  
  80. # confirmation #
  81. alias mv='mv -i'
  82. alias cp='cp -i'
  83. alias ln='ln -i'
  84.  
  85. # Parenting changing perms on / #
  86. alias chown='chown --preserve-root'
  87. alias chmod='chmod --preserve-root'
  88. alias chgrp='chgrp --preserve-root'
  89.  
  90. # reload bash config
  91. alias reload="source ~/.bashrc"
  92.  
  93. # Manage packages easier
  94. if [ -f /usr/bin/apt ]; then
  95.   alias update='sudo apt update'
  96.   alias upgrade='sudo apt update && sudo apt dist-upgrade'
  97.   alias install='sudo apt install'
  98. fi
  99.  
  100. if [ -f /usr/bin/pacman ]; then
  101.   alias update='sudo pacman -Syyy'
  102.   alias upgrade='sudo pacman -Syu'
  103.   alias install='sudo pacman -S'
  104. fi
  105.  
  106. ## Functions
  107. # Make a directory, then go there
  108. md() {
  109.     test -n "$1" || return
  110.     mkdir -p "$1" && cd "$1"
  111. }
  112.  
  113. # "path" shows current path, one element per line.
  114. # If an argument is supplied, grep for it.
  115. path() {
  116.     test -n "$1" && {
  117.         echo $PATH | perl -p -e "s/:/\n/g;" | grep -i "$1"
  118.     } || {
  119.         echo $PATH | perl -p -e "s/:/\n/g;"
  120.     }
  121. }
  122.  
  123. extract () {
  124.   if [ -f $1 ] ; then
  125.     case $1 in
  126.       *.tar.bz2)   tar xjvf $1    ;;
  127.       *.tar.gz)    tar xzvf $1    ;;
  128.       *.tar.xz)    tar xvf $1    ;;
  129.       *.bz2)       bzip2 -d $1    ;;
  130.       *.rar)       unrar2dir $1    ;;
  131.       *.gz)        gunzip $1    ;;
  132.       *.tar)       tar xf $1    ;;
  133.       *.tbz2)      tar xjf $1    ;;
  134.       *.tgz)       tar xzf $1    ;;
  135.       *.zip)       unzip2dir $1     ;;
  136.       *.Z)         uncompress $1    ;;
  137.       *.7z)        7z x $1    ;;
  138.       *.ace)       unace x $1    ;;
  139.       *)           echo "'$1' cannot be extracted via extract()"   ;;
  140.     esac
  141.   else
  142.     echo "'$1' is not a valid file"
  143.   fi
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement