└── bashrc /bashrc: -------------------------------------------------------------------------------- 1 | # shellcheck disable=SC1090 2 | # shellcheck disable=SC1091 3 | 4 | # Enable bash_completion 5 | [ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion 6 | [ -f /usr/share/bash-completion/bash_completion/bash_completion ] && . /usr/share/bash-completion/bash_completion 7 | [ -f /etc/bash_completion ] && . /etc/bash_completion 8 | [ -f /usr/share/doc/pkgfile/command-not-found.bash ] && . /usr/share/doc/pkgfile/command-not-found.bash 9 | 10 | if [ "$TERM" = "xterm-kitty" ]; then 11 | source <(kitty + complete setup bash) 12 | fi 13 | 14 | # Set commandline editor to vim 15 | # C-x C-e 16 | export VISUAL=vim 17 | 18 | # Use the trash can 19 | if command /usr/local/bin/trash &>/dev/null; then 20 | alias rm=/usr/local/bin/trash 21 | fi 22 | 23 | # Use gpg-agent for ssh 24 | test -f ~/.gpg-agent-info && . ~/.gpg-agent-info 25 | 26 | # Colourise commands 27 | if command grc &>/dev/null; then 28 | alias grc="grc -es --colour=auto" 29 | alias df='grc df' 30 | alias diff='grc diff' 31 | alias docker='grc docker' 32 | alias du='grc du' 33 | alias env='grc env' 34 | alias make='grc make' 35 | alias gcc='grc gcc' 36 | alias g++='grc g++' 37 | alias id='grc id' 38 | alias lsof='grc lsof' 39 | alias netstat='grc netstat' 40 | alias ping='grc ping' 41 | alias ping6='grc ping6' 42 | alias traceroute='grc traceroute' 43 | alias traceroute6='grc traceroute6' 44 | alias head='grc head' 45 | alias tail='grc tail' 46 | alias dig='grc dig' 47 | alias mount='grc mount' 48 | alias ps='grc ps' 49 | alias ifconfig='grc ifconfig' 50 | fi 51 | # shellcheck disable=SC2010 52 | if ls --version 2>/dev/null | grep -q GNU; then 53 | alias ls='ls --color' 54 | else 55 | alias ls='ls -G' 56 | fi 57 | 58 | # Single window gvim 59 | if command -v gvim &> /dev/null; then 60 | alias gvim='gvim --remote-silent' 61 | fi 62 | # Single window mvim 63 | if command -v mvim &> /dev/null; then 64 | alias mvim='mvim --remote-silent' 65 | fi 66 | 67 | # Put brew sbin into PATH 68 | if [ -d /usr/local/sbin ]; then 69 | export PATH="/usr/local/sbin:$PATH" 70 | fi 71 | 72 | # Make gettext availiable from brew 73 | if [ -d /usr/local/opt/gettext/bin ]; then 74 | export PATH="/usr/local/opt/gettext/bin:$PATH" 75 | fi 76 | 77 | # Add ~/local/*/bin to PATH 78 | # shellcheck disable=SC2155 79 | export PATH=$(printf "%s:" ~/local/*/bin):$PATH 80 | 81 | # Allow changing into some dirs directly 82 | CDPATH=.:~/Projects:~/projects 83 | 84 | # Load local bash-completions 85 | if [ -d ~/local/bash_completion/bash_completion.d/ ]; then 86 | for bc in ~/local/bash_completion/bash_completion.d/*; do 87 | source "$bc" 88 | done 89 | fi 90 | 91 | # Case insensitive tab-completion 92 | bind "set completion-ignore-case on" 93 | bind "set show-all-if-ambiguous on" 94 | 95 | # Show mathing parenthesis 96 | bind "set blink-matching-paren on" 97 | 98 | # Add some colour 99 | bind "set colored-completion-prefix on" 100 | bind "set colored-stats on" 101 | bind "set visible-stats on" 102 | 103 | # Don't wrap commandline 104 | # bind "set horizontal-scroll-mode on" 105 | 106 | # Allow completion in the middle of words 107 | bind "set skip-completed-text on" 108 | 109 | # Search using command line up up and down arrow 110 | bind '"\e[A": history-search-backward' 111 | bind '"\e[B": history-search-forward' 112 | 113 | # ctrl + arrow keys to move words 114 | bind '"\e[1;2C":forward-word' 115 | bind '"\e[1;2D":backward-word' 116 | 117 | # vi mode 118 | # set -o vi 119 | # bind "set show-mode-in-prompt on" 120 | # bind "set vi-ins-mode-string" 121 | # bind "set vi-cmd-mode-string +" 122 | 123 | # Setup bash history 124 | HISTCONTROL=ignoreboth 125 | HISTSIZE=-1 126 | HISTTIMEFORMAT='%F %T: ' 127 | shopt -s histappend 128 | shopt -s cmdhist 129 | 130 | # Enable extended globs 131 | shopt -s extglob 132 | 133 | # List running background jobs before exiting 134 | shopt -s checkjobs 135 | 136 | # Show dot-files when tab completing 137 | shopt -s dotglob 138 | 139 | # expand ** and **/ 140 | shopt -s globstar 141 | 142 | # Go stuff 143 | if [ -d ~/projects/go ]; then 144 | export GOPATH=~/projects/go 145 | fi 146 | if [ -d ~/Private/projects/go ]; then 147 | export GOPATH=~/Private/projects/go 148 | fi 149 | if [ -n "$GOPATH" ]; then 150 | export PATH=$PATH:$GOPATH/bin 151 | fi 152 | 153 | # Setup rvm 154 | if [ -s ~/.rvm/scripts/rvm ]; then 155 | source ~/.rvm/scripts/rvm 156 | source ~/.rvm/scripts/completion 157 | export PATH="$PATH:$HOME/.rvm/bin" 158 | fi 159 | 160 | # Prompt 161 | function __prompt_cmd 162 | { 163 | local exit_status=$? 164 | local blue="\\[\\e[34m\\]" 165 | local red="\\[\\e[31m\\]" 166 | local green="\\[\\e[32m\\]" 167 | local yellow="\\[\\e[33m\\]" 168 | local normal="\\[\\e[m\\]" 169 | 170 | local status_color 171 | if [ $exit_status != 0 ]; then 172 | status_color="$red" 173 | else 174 | status_color="$blue" 175 | fi 176 | PS1="" 177 | 178 | PS1+="${status_color}╭${normal}[$yellow\\D{%T}$normal] " 179 | if [ "$USER" = "vagrant" ]; then 180 | PS1+="$red\\u$normal" 181 | else 182 | PS1+="\\u" 183 | fi 184 | PS1+="@" 185 | if [ "$HOSTNAME" = "sandbox" ]; then 186 | PS1+="$red\\h$normal" 187 | else 188 | PS1+="\\h" 189 | fi 190 | PS1+="$blue \\w$normal" 191 | PS1+="\\n" 192 | 193 | local let_line 194 | 195 | # git based on https://github.com/jimeh/git-aware-prompt/ 196 | local branch 197 | if branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null); then 198 | if [ "$branch" = "HEAD" ]; then 199 | branch='detached*' 200 | fi 201 | let_line+="${yellow}${branch}" 202 | # shellcheck disable=SC2155 203 | local stash=$(git stash list 2>/dev/null) 204 | if [ -n "$stash" ]; then 205 | let_line+="^" 206 | fi 207 | # shellcheck disable=SC2155 208 | local status=$(git status --porcelain 2> /dev/null) 209 | if [ -n "$status" ]; then 210 | let_line+="*" 211 | fi 212 | 213 | let_line+="$normal " 214 | fi 215 | 216 | # Python virtualenv 217 | if [ -n "$VIRTUAL_ENV" ]; then 218 | let_line+="$green${VIRTUAL_ENV##*/}$normal " 219 | fi 220 | 221 | # RVM 222 | if command rvm-prompt &> /dev/null; then 223 | if [ -n "$(rvm-prompt g)" ]; then 224 | let_line+="$red$(rvm-prompt)$normal " 225 | fi 226 | fi 227 | 228 | # GOPATH 229 | if [ "${PWD##$GOPATH}" != "${PWD}" ]; then 230 | let_line+="${blue}Good to Go!$normal " 231 | fi 232 | 233 | if [ -n "$let_line" ]; then 234 | PS1+="${status_color}│$normal $let_line" 235 | PS1+="\\n" 236 | fi 237 | 238 | # Default prompts 239 | local sprompt='λ' 240 | local fprompt='λ' 241 | 242 | # Seassonal prompts 243 | local md=$(date +%m%d) 244 | if [ "$md" -ge 1201 ] && [ "$md" -ge 1223 ]; then 245 | sprompt='🎄' 246 | fprompt='☃️' 247 | fi 248 | if [ "$md" -eq 1224 ]; then 249 | sprompt='🎅🏻' 250 | fprompt='🎁' 251 | fi 252 | if [ "$md" -eq 0704 ]; then 253 | sprompt='🇺🇸 ' 254 | fprompt='🎇' 255 | fi 256 | 257 | if [ $exit_status != 0 ]; then 258 | prompt="${fprompt}" 259 | else 260 | prompt="${sprompt}" 261 | fi 262 | 263 | PS1+="${status_color}╰${normal} ${prompt} " 264 | 265 | # Save history continuously 266 | history -a 267 | } 268 | 269 | test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash" 270 | 271 | PROMPT_COMMAND=__prompt_cmd 272 | # Don't have python virtual environment set prompt 273 | export VIRTUAL_ENV_DISABLE_PROMPT=1 274 | 275 | if command -v fortune &> /dev/null; then 276 | printf '\033[0;35m' 277 | fortune -e -s 278 | printf '\033[0m' 279 | fi 280 | 281 | --------------------------------------------------------------------------------