bashrc

   1 [[ -d ~/.cache/wal ]] &&
   2 cat ~/.cache/wal/sequences &&
   3 source ~/.cache/wal/colors-tty.sh
   4 
   5 [[ $- != *i* ]] && return
   6 
   7 stty -ixon
   8 shopt -s autocd
   9 shopt -s globstar
  10 
  11 [[ $TERM == xterm* ]] &&
  12 TERM=xterm
  13 
  14 HISTSIZE= HISTFILESIZE=
  15 HISTTIMEFORMAT='[%F %T] '
  16 HISTCONTROL=ignorespace:ignoredups
  17 
  18 PROMPT_COMMAND=precmd
  19 function precmd(){ # {{{
  20     history -a
  21     ps1_col=$(( (${ps1_col:-$RANDOM} + 1) % 6 ))
  22     printf '\e]0;%s@%s: %s\a' $USER $HOSTNAME "${PWD/$HOME/\~}"
  23 } # }}}
  24 
  25 PS1='\n\[\e[1;3`ps1_col`m\] \w`ps1_git` \$\[\e[0m\] '
  26 function ps1_col(){ # {{{
  27     [[ $SUDO_USER ]] && echo 1 ||
  28     echo $(( $ps1_col + 2 ))
  29 } # }}}
  30 function ps1_git(){ # {{{
  31     [[ $(git rev-parse --show-toplevel 2>&-) ]] || return
  32     local a=$(git rev-parse --abbrev-ref HEAD)
  33     local b=$(git status -s | wc -l)
  34     local c=$(git log --branches --not --remotes --oneline | wc -l)
  35     echo " [$a:+$b:*$c]" | sed 's/:[+*]0//g'
  36 } # }}}
  37 
  38 alias vi='vim -p'
  39 alias rg='ranger'
  40 alias tm='tmux a || tmux'
  41 
  42 alias tt='tree -FlCL 2'
  43 alias ll='ls -Flh --color'
  44 alias lll='ll -A --time-style +"%F %T"'
  45 alias ttt='tt -L 10'
  46 
  47 alias d='cd ~/Desktop'
  48 alias l='cd ~/Projects/lexa.by'
  49 
  50 alias grep='grep -i --color'
  51 alias rsync='rsync -iPvh -rt'
  52 
  53 alias backup='rsync -L --exclude lost+\* /media/Home ~/.Backup'
  54 alias backup-camera='adb pull /sdcard/DCIM/Camera ~/Pictures'
  55 
  56 alias mpv-audio='mpv --profile audio'
  57 alias mpv-history='tac ~/.config/mpv/history.log | less'
  58 alias mpv-fan='(read u; mpv $(curl -s $u | grep -ao "http:.*\.mp4")) <<<'
  59 
  60 alias proxy-list='w3m -dump -cols 100 socks-proxy.net | sed "1,41d; 123,\$d"'
  61 
  62 u(){ # {{{
  63     [[ ! $@ ]] &&
  64     cd ~/.dotfiles &&
  65     return
  66 
  67     (u; vi $(for i in "$@"; do
  68         [[ -f config/$i ]] &&
  69         echo config/$i || echo $i
  70     done))
  71 } # }}}
  72 complete -W "$(u; find * -type f | sed 's#^config/##')" u
  73 
  74 eval $(keychain -q --eval)
  75 
  76 [[ -d ~/.local/etc/bash_completion.d ]] &&
  77 source ~/.local/etc/bash_completion.d/*
  78 source /usr/share/bash-completion/bash_completion
  79 
  80 colors(){ # {{{
  81     echo
  82 
  83     for i in {0..7}; do
  84         echo -ne "  \e[7;3${i}m    \e[0m"
  85         echo -ne "\e[7;1;3${i}m    \e[0m"
  86     done
  87 
  88     echo
  89 
  90     for i in {0..7}; do
  91         echo -ne "  \e[7;3${i}m    \e[0m"
  92         echo -ne "\e[7;1;3${i}m    \e[0m"
  93     done
  94 
  95     echo
  96 } # }}}