Advertisement
learnlinuxtv

LearnLinux.tv .bashrc Example

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