*nohtml*

bashrc

   1 [[ $- != *i* ]] && return
   2 test -f ~/.config/colors/colors-${TERM:0:5} && cat $_
   3 
   4 stty -ixon
   5 shopt -s autocd
   6 shopt -s globstar
   7 
   8 HISTSIZE= HISTFILESIZE=
   9 HISTTIMEFORMAT='[%F %T] '
  10 HISTCONTROL=ignorespace:ignoredups
  11 
  12 PROMPT_COMMAND=precmd
  13 function precmd(){ # {{{
  14     history -a
  15     [[ $TERM == xterm ]] && printf '\e[0 q'
  16     ps1_col=$(( (${ps1_col:-$RANDOM} + 1) % 6 ))
  17     printf '\e]0;%s@%s:%s\a' $USER $HOSTNAME "${PWD/~/\~}"
  18 } # }}}
  19 
  20 PS1='\n\[\e[1;3`ps1_col`m\] `ps1_ssh`\w`ps1_git` \$\[\e[0m\] '
  21 function ps1_col(){ # {{{
  22     [[ $SUDO_USER ]] && echo 1 ||
  23     echo $(( $ps1_col + 2 ))
  24 } # }}}
  25 function ps1_ssh(){ # {{{
  26     [[ $SSH_TTY ]] && echo $USER@$HOSTNAME:
  27 } # }}}
  28 function ps1_git(){ # {{{
  29     [[ $(git rev-parse --show-toplevel 2>&-) ]] || return
  30     local a=$(git rev-parse --abbrev-ref HEAD 2>&-)
  31     local b=$(git status -s | wc -l)
  32     local c=$(git log --branches --not --remotes --oneline | wc -l)
  33     echo " [$a:*$c:+$b]" | sed 's/:[+*]0//g'
  34 } # }}}
  35 
  36 alias v='vi'
  37 alias vi='vim -p'
  38 
  39 alias gt='git'
  40 alias rg='ranger'
  41 alias tm='tmux a || tmux'
  42 
  43 alias ll='ls -h --color'
  44 alias lll='ll -al --full-time'
  45 
  46 u(){ # {{{
  47     [[ ! $@ ]] && cd ~/.dotfiles && return
  48     (u; vi $(for i in "$@"; do find -type f -wholename "*$i"; done))
  49 }
  50 
  51 _u(){
  52     COMPREPLY=($(compgen -W "$(
  53         u; find * -type f | sed 's#^\(config\|local\)/##'
  54     )" -- ${COMP_WORDS[COMP_CWORD]}))
  55 }
  56 
  57 complete -F _u u # }}}
  58 
  59 alias grep='grep -i --color'
  60 alias rsync='rsync -iPvh -rtl'
  61 
  62 alias backup='rsync -F /home ~/.Backup'
  63 alias backup-android='adb pull -a /sdcard/DCIM/Camera ~/Pictures'
  64 alias backup-iphone='rsync phone:/User/Media/DCIM/*/ ~/Pictures/Camera'
  65 
  66 alias mpv-audio='mpv --profile=audio'
  67 alias mpv-history='tac ~/.config/mpv/history.log | less'
  68 alias mpv-fan='(read u; mpv $(curl -s $u | grep -ao "http:.*\.mp4")) <<<'
  69 
  70 alias mc="TERM=$TERM mc"
  71 alias htop="TERM=$TERM htop"
  72 
  73 eval $(keychain -q --eval)
  74 test -f ~/.local/lib/z.sh && source $_
  75 source /usr/share/bash-completion/bash_completion
  76 
  77 [[ $TERM == linux || $TERM == xterm* ]] && TERM=xterm