[download]

bashrc

   1 [[ $- != *i* ]] && return
   2 test -f ~/.theme/$VIM${TERM:0:5} && cat $_
   3 test -n "$SSH_TTY" && pfetch && colors -c
   4 
   5 stty -ixon
   6 shopt -s autocd
   7 shopt -s globstar
   8 shopt -s lithist
   9 
  10 HISTFILESIZE= HISTSIZE=
  11 HISTTIMEFORMAT='[%F %T] '
  12 HISTFILE=~/.bash_history
  13 HISTCONTROL=ignorespace:ignoredups
  14 cat ~/.bash_202??? > $HISTFILE
  15 
  16 PROMPT_COMMAND=precmd
  17 function precmd(){ # {{{
  18     HISTFILE=~/.bash_$(date +%Y%m)
  19     history -a
  20 
  21     test -f ~/.theme/$VIM${TERM:0:5} && cat $_
  22     ps1_col=$(( (${ps1_col:-$RANDOM} + 1) % 6 ))
  23 
  24     printf '\e]0;%s%s@%s:%s\a' "${SSH_TTY:+$(icon os) }" $USER $HOSTNAME "${PWD/~/\~}"
  25 } # }}}
  26 
  27 PS1='\n\[\e[1;3`ps1_col`m\] `ps1_ssh`\w`ps1_git` \$\[\e[0m\] '
  28 function ps1_col(){ # {{{
  29     [[ $SUDO_UID ]] && echo 1 || echo $(( ps1_col + 2 ))
  30 } # }}}
  31 function ps1_ssh(){ # {{{
  32     [[ $SSH_TTY ]] && echo $(icon os) $USER@$HOSTNAME:
  33 } # }}}
  34 function ps1_git(){ # {{{
  35     git rev-parse 2>&-|| return
  36 
  37     local st=$(git st  2>&- | wc -l)
  38     local up=$(git out 2>&- | wc -l)
  39     local br=$(git symbolic-ref --short HEAD)
  40 
  41     echo " [$br:*$up:+$st]" | sed 's/:[+*]0//g'
  42 } # }}}
  43 
  44 alias v='vi'
  45 alias vi='vim -p'
  46 
  47 alias gt='git'
  48 alias rg='ranger'
  49 alias tm='tmux a || tmux'
  50 alias d='cd ~/.dotfiles'
  51 
  52 alias ll='ls  -h  --color'
  53 alias lll='ll -al --full-time'
  54 
  55 alias ip='ip -color=auto'
  56 alias wget='wget --no-hsts'
  57 alias grep='grep -i --color'
  58 alias dfc='dfc -wdq name -p /dev'
  59 
  60 alias rsync='rsync -ihv -rtl'
  61 alias backup='rsync -F /home/ /data/Backup'
  62 alias backup-camera='rsync /run/**/DCIM/*/ ~/Camera'
  63 
  64 alias mpv-audio='mpv --profile=audio'
  65 alias mpv-fan='(read u; mpv $(curl -s $u | grep -ao "https:.*\.mp4")) <<<'
  66 
  67 alias mc="TERM=$TERM mc"
  68 alias htop="TERM=$TERM htop"
  69 
  70 [[ $TERM == xterm ]] && printf '\e[0 q'
  71 [[ $TERM == linux || $TERM == xterm* ]] && TERM=xterm
  72 
  73 test -f /usr/share/bash-completion/bash_completion && . $_
  74 command -v command_not_found_handle >&- || command_not_found_handle(){ # {{{
  75     local cmd pkg
  76 
  77     if command -v pkgfile >&-; then
  78         cmd='pacman -S'
  79         pkg=$(pkgfile -qb $1)
  80     elif command -v pacman >&-; then
  81         cmd='pacman -S'
  82         pkg=$(pacman  -Fq $1)
  83         pkg=${pkg[@]#*/}
  84     elif command -v apk >&-; then
  85         cmd='apk add'
  86         pkg=$(apk search -q cmd:$1)
  87     fi
  88 
  89     [[ ! $pkg ]] && echo "$1: команда не найдена" && return 1
  90 
  91     echo
  92     echo "Команда «$1» не найдена, но может быть установлена с помощью:"
  93     echo
  94     printf "sudo $cmd %s\n" "${pkg[@]}"
  95     echo
  96 } # }}}