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 # If not running interactively, don't do anything
[[ $- != *i* ]] && return [[ $- != *i* ]] && return
# {{{ settings
HISTSIZE=1000 HISTSIZE=1000
HISTFILE="$HOME/.bash_history.$UID" HISTFILE="$HOME/.bash_history.$UID"
HISTCONTROL=ignoredups HISTCONTROL=ignoredups
@ -13,21 +12,14 @@ export PAGER=less
export EDITOR=vim export EDITOR=vim
export TIME_STYLE=long-iso export TIME_STYLE=long-iso
export SSH_AUTH_SOCK="$HOME/.ssh/ssh_auth_sock" export SSH_AUTH_SOCK="$HOME/.ssh/ssh_auth_sock"
# }}}
# {{{ prompt ((UID)) && ps_clr=53 || ps_clr=52
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
# just a colored version of [ $USER $HOSTNAME:$CWD ] # 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 unset ps_clr
PROMPT_COMMAND=prompt_command
# }}} unalias ls ld ll 2>/dev/null
# {{{ aliases
beep() { printf "\007"; } beep() { printf "\007"; }
fixterm() { printf "c"; } fixterm() { printf "c"; }
@ -38,7 +30,8 @@ whence() { command -v "$@"; }
# ls # ls
ls() { command ls --color=auto --group-directories-first "$@"; } ls() { command ls --color=auto --group-directories-first "$@"; }
ll() { command ls -lha --color=auto --group-directories-first "$@"; } ll() { ls -alh "$@"; }
ll() { ls -dlh "$@"; }
# git # git
gci() { command git commit "$@"; } gci() { command git commit "$@"; }
@ -56,36 +49,10 @@ atmux() { tmux attach; }
# sudo # sudo
sush() { command sudo -Es; } sush() { command sudo -Es; }
# vim
vi() { command vim "$@"; }
# }}}
# {{{ plugins and traps
# bash-completion # bash-completion
completion_path='/usr/share/bash-completion/bash_completion' completion_path='/usr/share/bash-completion/bash_completion'
[[ -r "$completion_path" ]] && source "$completion_path" [[ -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) # 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_msg='\e[31m>>\e[0m exit \e[31m%s\e[0m\n'
trap 'printf "$trap_msg" "$?" >&2' ERR trap 'printf "$trap_msg" "$?" >&2' ERR
# }}}

View file

@ -1,5 +1,5 @@
# some distributions love to force some aliases upon user :< # some distributions love to force some aliases upon user :<
unalias ls ll ld 2>/dev/null unalias ls ld ll 2>/dev/null
beep() { printf $'\007' } beep() { printf $'\007' }
fixterm() { printf $'c' } fixterm() { printf $'c' }
@ -15,7 +15,7 @@ if [[ -x $(whence -p exa) ]]; then
ll() { ls -alg $@ } ll() { ls -alg $@ }
ld() { ls -dlg $@ } ld() { ls -dlg $@ }
else else
ls() { command ls --color=auto $@ } ls() { command ls --color=auto --group-directories-first $@ }
ll() { ls -alh $@ } ll() { ls -alh $@ }
ld() { ls -dlh $@ } ld() { ls -dlh $@ }
fi fi
@ -56,9 +56,6 @@ atmux() { tmux attach || tmux }
# sudo # sudo
sush() { command sudo -Es } sush() { command sudo -Es }
# vim
vi() { command vim $@ }
# grc # grc
if [[ -x $(whence -p grc) ]]; then if [[ -x $(whence -p grc) ]]; then
cmds=(\ cmds=(\

View file

@ -20,8 +20,8 @@ typeset -A prompt_symbols=(
typeset -A prompt_colors=( typeset -A prompt_colors=(
fg 15 fg 15
user 53 user 53
ssh 90
root 52 root 52
ssh 90
host 237 host 237
cwd 234 cwd 234
ro 124 ro 124