1
0
Fork 0

bash: remove unnecessary, update the rest; zsh: minor tweaks

This commit is contained in:
Von Random 2022-08-22 02:57:33 +03:00
parent ec982fd1b0
commit cfa47c3630
3 changed files with 12 additions and 48 deletions

51
bashrc
View file

@ -2,7 +2,6 @@
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# {{{ settings
HISTSIZE=1000
HISTFILE="$HOME/.bash_history.$UID"
HISTCONTROL=ignoredups
@ -13,21 +12,14 @@ export PAGER=less
export EDITOR=vim
export TIME_STYLE=long-iso
export SSH_AUTH_SOCK="$HOME/.ssh/ssh_auth_sock"
# }}}
# {{{ prompt
prompt_command() {
case "$TERM" in
(screen*) printf '\ek%s\e\\' "${HOSTNAME%%.*}";;
(*) printf '\e]0;%s\a' "${HOSTNAME%%.*}";;
esac
}
((UID)) && ps_clr=4 || ps_clr=1
((UID)) && ps_clr=53 || ps_clr=52
# just a colored version of [ $USER $HOSTNAME:$CWD ]
printf -v PS1 '\\[\\e[0m\\][ \\[\\e[3%sm\\]\\u\\[\\e[0m\\] \\h:\\[\\e[32m\\w\\[\\e[0m\\] ]\n\\$ ' $ps_clr
printf -v PS1 '\\[\\e[0m\\]\\[\\e[48;5;%sm\\] \\u \\[\\e[48;5;237m\\] \\h \\[\\e[48;5;234m \\w \\[\\e[0m\\]\n\\$ ' $ps_clr
unset ps_clr
PROMPT_COMMAND=prompt_command
# }}}
# {{{ aliases
unalias ls ld ll 2>/dev/null
beep() { printf "\007"; }
fixterm() { printf "c"; }
@ -38,7 +30,8 @@ whence() { command -v "$@"; }
# ls
ls() { command ls --color=auto --group-directories-first "$@"; }
ll() { command ls -lha --color=auto --group-directories-first "$@"; }
ll() { ls -alh "$@"; }
ll() { ls -dlh "$@"; }
# git
gci() { command git commit "$@"; }
@ -56,36 +49,10 @@ atmux() { tmux attach; }
# sudo
sush() { command sudo -Es; }
# vim
vi() { command vim "$@"; }
# }}}
# {{{ plugins and traps
# bash-completion
completion_path='/usr/share/bash-completion/bash_completion'
[[ -r "$completion_path" ]] && source "$completion_path"
# grc
if [[ -x $(command -v grc) ]]; then
cmds=(\
cc configure cvs df diff dig gcc gmake id ip last lsof make mount \
mtr netstat ping ping6 ps tcpdump traceroute traceroute6 \
)
for cmd in "${cmds[@]}"; do
alias $cmd="command grc -es --colour=auto $cmd"
done
unset cmds cmd
fi
# some cool git stuff
gdiff() { /usr/bin/git diff --color "$@"; }
gdf() {
local difftool
if difftool=$(command -v sdiff-so-fancy); then
gdiff "$@" | "$difftool" | less --tabs=4 -RSFX
else
gdiff "$@"
fi
}
# we want to see exit code on error (it also has to be the last entry here)
trap_msg='\e[31m>>\e[0m exit \e[31m%s\e[0m\n'
trap 'printf "$trap_msg" "$?" >&2' ERR
# }}}