configuration/yashrc

88 lines
2.4 KiB
Plaintext
Raw Normal View History

2019-08-23 17:18:24 +02:00
# 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
2019-10-16 14:47:43 +02:00
HISTFILE=
2019-08-23 17:18:24 +02:00
HISTSIZE=5000
2019-10-16 14:47:43 +02:00
HISTRMDUP=5000
2019-10-29 19:41:40 +01:00
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
2017-02-09 11:00:03 +01:00
# Get ourselves a nice prompt
2017-05-19 17:06:37 +02:00
ks() { s="$?" ; $* ; return "$s" ; }
prompt_git() {
if git status 2>/dev/null 1>&2; then
2018-10-22 23:09:42 +02:00
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')"
2019-08-23 17:18:24 +02:00
local status="$({ echo OK; git status --porcelain | sed 's/\(..\).*/\1/'; } | tail -1)"
2018-10-22 23:09:42 +02:00
echo " (${branch}${behind}${before}|${status})"
fi
}
2017-05-19 17:06:37 +02:00
prompt_pwd() {
pwd | sed -e "s_${HOME}_~_" -e 's_\(/*\.*.\)[^/]*/_\1/_g'
2017-05-19 17:06:37 +02:00
}
2018-11-30 10:01:33 +01:00
prompt_agent() {
[ -z "$SSH_AGENT_PID" ] || echo " (A)"
}
2019-11-27 14:45:44 +01:00
prompt_mail() {
unread="$(notmuch count tag:unread)"
[ "$unread" = "0" ] || echo " ($unread mails)"
}
2017-05-19 17:06:37 +02:00
prompt_status() {
2017-02-09 11:00:03 +01:00
if [ "$?" = "0" ]
2018-10-22 23:09:42 +02:00
then echo "$"
else echo "%"
2017-02-09 11:00:03 +01:00
fi
}
2019-08-23 17:18:24 +02:00
prompt_date() {
date +%H:%M:%S
}
BOLD="\fo."
GREEN="\fg."
RESET="\fD."
2019-11-27 14:45:44 +01:00
PS1="$BOLD[\$(ks prompt_date)]$RESET $GREEN\$(ks prompt_pwd)$RESET\$(ks prompt_git)\$(ks prompt_agent)\$(ks prompt_mail) \$(prompt_status) "
2017-05-19 17:06:37 +02:00
unset BOLD
2017-02-09 11:00:03 +01:00
unset GREEN
unset RESET
# Color ls
2019-03-11 10:40:04 +01:00
ls_() {
lr -1FGG "$@" | git column --mode=dense --padding=3
}
alias ls="ls_"
2019-01-22 16:37:13 +01:00
alias ll="lr -Fl1Ghov"
2017-02-09 11:00:03 +01:00
2018-10-08 13:34:50 +02:00
# There is only one vis
alias vim="vis"
alias vi="vis"
alias nano="vis"
2017-02-09 11:00:03 +01:00
# Ready for ssh'ing
alias agent='eval "$(ssh-agent)" && ssh-add'
2017-09-26 10:00:11 +02:00
alias unlock='gpg-connect-agent <<<bye'
2017-02-09 11:00:03 +01:00
alias weechat="ssh -t weechat@Chatmachine abduco -A weechat"
2019-11-27 14:45:44 +01:00
alias agenda="khal list today 7d"
2018-02-26 11:52:05 +01:00
2017-05-19 17:06:37 +02:00
go() {
2017-10-30 23:20:35 +01:00
dir="$(lr /home /data /etc -t '(name ~~ ".*" && prune || print) && type = d && !(name = ".git")' \
2017-05-19 17:06:37 +02:00
| fzf --height 10 \
)"
2017-02-09 11:00:03 +01:00
[ -n "$dir" ] && cd "$dir" || false
}
terminfo() {
infocmp -x | ssh $@ 'cat > $TERM.info && tic -x $TERM.info && rm $TERM.info'
}