83 lines
2.2 KiB
Plaintext
83 lines
2.2 KiB
Plaintext
# if yash is built with line-editing enabled...
|
|
if command --identify --builtin-command bindkey >/dev/null; then
|
|
# print job status update ASAP, but only while line-editing
|
|
set --notify-le
|
|
|
|
# some terminfo data are broken; meta flags have to be ignored for UTF-8
|
|
set --le-no-conv-meta
|
|
|
|
# I'll try emacs mode
|
|
set --emacs
|
|
fi
|
|
|
|
# set history
|
|
HISTFILE=
|
|
HISTSIZE=5000
|
|
HISTRMDUP=5000
|
|
history -r "$HOME/.yash_history"
|
|
trap 'h=$(mktemp) && history -w $h && history -c && history -r "$HOME/.yash_history" && history -r $h && history -w $HOME/.yash_history && rm $h' EXIT
|
|
|
|
# Get ourselves a nice prompt
|
|
ks() { s="$?" ; $* ; return "$s" ; }
|
|
prompt_git() {
|
|
if git status 2>/dev/null 1>&2; then
|
|
local branch="$(git branch | sed -n 's/^\* (*\(.* \)*\([^ )]*\))*$/\2/p')"
|
|
local behind="$(git status --branch --porcelain=2 | sed -n 's/^# branch\.ab.*-\([^0].*\)$/⇃\1/p')"
|
|
local before="$(git status --branch --porcelain=2 | sed -n 's/^# branch\.ab +\([^0].*\) .*$/↿\1/p')"
|
|
local status="$({ echo OK; git status --porcelain | sed 's/\(..\).*/\1/'; } | tail -1)"
|
|
|
|
echo " (${branch}${behind}${before}|${status})"
|
|
fi
|
|
}
|
|
prompt_pwd() {
|
|
pwd | sed -e "s_${HOME}_~_" -e 's_\(/*\.*.\)[^/]*/_\1/_g'
|
|
}
|
|
prompt_agent() {
|
|
[ -z "$SSH_AGENT_PID" ] || echo " (A)"
|
|
}
|
|
prompt_status() {
|
|
if [ "$?" = "0" ]
|
|
then echo "$"
|
|
else echo "%"
|
|
fi
|
|
}
|
|
prompt_date() {
|
|
date +%H:%M:%S
|
|
}
|
|
BOLD="\fo."
|
|
GREEN="\fg."
|
|
RESET="\fD."
|
|
PS1="$BOLD[\$(ks prompt_date)]$RESET $GREEN\$(ks prompt_pwd)$RESET\$(ks prompt_git)\$(ks prompt_agent) \$(prompt_status) "
|
|
unset BOLD
|
|
unset GREEN
|
|
unset RESET
|
|
|
|
# Color ls
|
|
ls_() {
|
|
lr -1FGG "$@" | git column --mode=dense --padding=3
|
|
}
|
|
alias ls="ls_"
|
|
alias ll="lr -Fl1Ghov"
|
|
|
|
# There is only one vis
|
|
alias vim="vis"
|
|
alias vi="vis"
|
|
alias nano="vis"
|
|
|
|
# Ready for ssh'ing
|
|
alias agent='eval "$(ssh-agent)" && ssh-add'
|
|
alias unlock='gpg-connect-agent <<<bye'
|
|
|
|
alias weechat="ssh -t weechat@Chatmachine abduco -A weechat"
|
|
|
|
go() {
|
|
dir="$(lr /home /data /etc -t '(name ~~ ".*" && prune || print) && type = d && !(name = ".git")' \
|
|
| fzf --height 10 \
|
|
)"
|
|
[ -n "$dir" ] && cd "$dir" || false
|
|
}
|
|
|
|
terminfo() {
|
|
infocmp -x | ssh $@ 'cat > $TERM.info && tic -x $TERM.info && rm $TERM.info'
|
|
}
|