bashrc

   1 [[ $- != *i* ]] && return
   2 
   3 stty -ixon
   4 
   5 shopt -s autocd
   6 shopt -s cdspell
   7 shopt -s globstar
   8 
   9 HISTSIZE= HISTFILESIZE=
  10 HISTTIMEFORMAT='[%F %T] '
  11 HISTCONTROL=ignorespace:ignoredups
  12 
  13 PROMPT_COMMAND=precmd
  14 function precmd(){ # {{{
  15     history -a
  16     printf '\e]0;%s@%s: %s\a' $USER $HOSTNAME "${PWD/$HOME/\~}"
  17 } # }}}
  18 
  19 PS1='\n\[\e[`ps1_hc`m\] \w`ps1_vcs` \$\[\e[0m\] '
  20 function ps1_hc(){ # {{{
  21     local c=37 f=~/.hostcolor
  22 
  23     [[ $SSH_TTY && -f $f ]] && c=$(< $f)
  24     [[ $SUDO_USER ]] && c=31
  25 
  26     echo $c
  27 } # }}}
  28 function ps1_vcs(){ # {{{
  29     local s
  30 
  31     [[ -d .hg || -d ../.hg || -d ../../.hg ]] &&
  32     s="hg:$(hg branch) +$(hg status | wc -l)"
  33 
  34     [[ -d .git || -d ../.git || -d ../../.git ]] &&
  35     s="git:$(git rev-parse --abbrev-ref HEAD) +$(git status --porcelain | wc -l)"
  36 
  37     [[ $s ]] &&
  38     echo " [${s/ +0/}]"
  39 } # }}}
  40 
  41 # Aliases {{{
  42 
  43 alias vi='vim'
  44 alias vim='TERM=xterm vim'
  45 
  46 alias tm='tmux a || tmux'
  47 
  48 alias tt='tree -FlCL 2'
  49 alias ll='ls -Falh --color'
  50 
  51 alias rg='ranger'
  52 alias ranger='ranger -r ~/.ranger'
  53 
  54 alias ggrep='grep -nR'
  55 alias grep='grep -iI --color'
  56 
  57 alias rsync='rsync -iPvh -tr'
  58 alias backup='rsync -L --delete --exclude-from <(cd ~
  59 find .* -maxdepth 0; find * -maxdepth 0 -type l) ~/ ~/.Backup'
  60 alias backup-camera='rsync /media/*/*/DCIM/Camera/ ~/.Camera'
  61 
  62 alias mpv-audio='mpv --profile audio'
  63 alias mpv-history='tac ~/.config/mpv/history.log | less'
  64 alias mpv-fan='(read u; mpv $(curl -s $u | grep -ao "http:.\+\.mp4")) <<<'
  65 
  66 u(){ local d=~/.dotfiles; [[ $1 ]] && (cd $d; vi -p "$@") || cd $d; }
  67 complete -W "$(u; find * -type f)" u
  68 
  69 # }}}
  70 # Colors {{{
  71 
  72 if [[ ! $SSH_TTY ]]; then
  73 
  74 printf "\e]11;#222228\a"
  75 printf "\e]10;#d8dade\a"
  76 
  77 printf "\e]4;0;#37373f\a"
  78 printf "\e]4;8;#4e4e56\a"
  79 
  80 printf "\e]4;1;#ff5f5f\a"
  81 printf "\e]4;9;#ff5f5f\a"
  82 
  83 printf "\e]4;2;#87af5f\a"
  84 printf "\e]4;10;#87af5f\a"
  85 
  86 printf "\e]4;3;#d7af87\a"
  87 printf "\e]4;11;#ffd75f\a"
  88 
  89 printf "\e]4;4;#5f5fff\a"
  90 printf "\e]4;12;#afafd7\a"
  91 
  92 printf "\e]4;5;#d75fff\a"
  93 printf "\e]4;13;#d75fff\a"
  94 
  95 printf "\e]4;6;#87d7d7\a"
  96 printf "\e]4;14;#87d7d6\a"
  97 
  98 printf "\e]4;7;#a8aaae\a"
  99 printf "\e]4;15;#d8dade\a"
 100 
 101 fi
 102 
 103 # }}}
 104 
 105 eval $(keychain -q --eval)
 106 source /usr/share/bash-completion/bash_completion
 107 [[ ! $SSH_TTY && $DISPLAY && $PWD == ~ ]] && cd ~/Desktop
 108