系統|一份bashrc模板
來自ofollow,noindex">https://gist.github.com/susanBuck/ee3a0a53d72198c1a244
# If not running interactively, don't do anything [ -z "$PS1" ] && return # ------------------------------------ # ALIASES # ------------------------------------ # Edit .bashrc alias bashedit='sudo open -a TextEdit ~/.bashrc' # Force terminal to recognize changes to .bashrc alias bashrefresh='source ~/.bashrc' # Ideal directory listing alias ll="ls -laFG" # -l list in long format # -F Display a... #slash (`/') immediately after each pathname that is a directory, #asterisk (`*') after each that is executable, #at sign (`@') after each symbolic link #equals sign (`=') after each socket, #percent sign (`%') after each whiteout, #vertical bar (`|') after each that is a FIFO. # -G = Color # -a = Show hidden files # Ask before removing files alias rm='rm -i' # Search history. Example usage: `histg git` to recent commands that use git alias histg="history | grep" # Get your current IP alias myip="curl http://ipecho.net/plain; echo" # Example alias for SSH'ing into a server alias myserver="ssh [email protected]" # Example alias for quickly getting to a commonly used directory alias htdocs='cd /Applications/MAMP/htdocs' # ------------------------------------ # Color variables # ------------------------------------ # Regular Colors Black='\e[0;30m' Red='\e[0;31m' Green='\e[0;32m' Yellow='\e[0;33m' Blue='\e[0;34m' Purple='\e[0;35m' Cyan='\e[0;36m' White='\e[0;37m' Light_Gray='\033[0;37m' # Bold BBlack='\e[1;30m' BRed='\e[1;31m' BGreen='\e[1;32m' BYellow='\e[1;33m' BBlue='\e[1;34m' BPurple='\e[1;35m' BCyan='\e[1;36m' BWhite='\e[1;37m' BLight_Gray='\033[1;37m' # Reset colors NONE="\e[0m" # ------------------------------------ # Configure prompt # Includes special handling for git repos # ------------------------------------ # When in a git repo, this method is used to determine the current branch function parse_git_branch { git branch 2>/dev/null | grep '^*' | sed 's_^..__' | sed 's_\(.*\)_(\1)_' } # When in a git repo, this method is used to determine if there are changes function git_dirty { git diff --quiet HEAD &>/dev/null [ $? == 1 ] && echo "!" } # Variables ps1_user="$Blue\u$NONE" ps1_host="$Green\h$NONE" ps1_dir="$Purple\w$NONE" ps1_git="$Cyan \$(parse_git_branch)$Red \$(git_dirty)$NONE " # Option 1 user@host:dir(branch)! $ # export PS1="${ps1_user}@${ps1_host}:${ps1_dir}${ps1_git}\$ " # Option 2 dir(branch)! $ #export PS1="${ps1_dir}${ps1_git}\$ " export PS1="${ps1_dir}${ps1_git}\$ " # ------------------------------------ # MOTD (Message of the Day) # What you see when Terminal opens # ------------------------------------ printf $BBlack echo "----------------------------" echo "Loaded ~/.bashrc" echo "" echo "To edit run: bashedit" echo "To refresh run: bashrefresh" echo "All aliases: alias" echo "" echo "You are: `whoami`" echo "You're in: `pwd`" echo "----------------------------" printf $NONE