configuration/yashrc

95 lines
2.7 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
# arrange history
HISTFILE=~/.yash_history
2019-08-23 17:18:24 +02:00
HISTSIZE=5000
2019-10-16 14:47:43 +02:00
HISTRMDUP=5000
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() {
porcelain="$(git status --branch --porcelain 2>/dev/null)"
if test "$?" = 0; then
2020-09-22 11:04:07 +02:00
local branch="$(printf '%s' "$porcelain" | sed -n 's/\.\.\..*//;1s/## //p')"
local behind="$(printf '%s' "$porcelain" | sed -n '1s/## .*behind \([0-9]*\).*/-\1/p')"
local ahead="$(printf '%s' "$porcelain" | sed -n '1s/## .*ahead \([0-9]*\).*/+\1/p')"
local status="$({ echo OK; printf '%s' "$porcelain" | sed '/##/d;s/\(..\).*/\1/'; } | tail -1)"
2018-10-22 23:09:42 +02:00
echo " (${branch}${behind}${ahead}|${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)"
}
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."
PS1="$BOLD[\$(ks prompt_date)]$RESET $GREEN\$(ks prompt_pwd)$RESET\$(ks prompt_git)\$(ks prompt_agent) \$(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
# ls_() {
# lr -1FGG "$@" | git column --mode=dense --padding=3
# }
# alias ls="ls_"
alias ls="ls --color=auto"
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@Hetzner 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
# Ledger
alias haccounts="hledger -I --alias '/.*:Accounts [^:]*:(.*)/=Accounts:\1' bal accounts"
alias ladd='ladd -a /data/documents/ledger/2020/main.journal /data/documents/ledger/*/main.journal'
2020-10-16 10:34:59 +02:00
alias is='hledger is -b $(date -d "7 months ago" +%Y-%m) -e $(date +%Y-%m) -MTA --tree -2'
alias cf='hledger cf -b $(date -d "7 months ago" +%Y-%m) -e $(date +%Y-%m) -MTA --tree -2'
2020-04-15 12:39:42 +02:00
alias bs='hledger bs not:accounts'
# Rust debugging
alias rustdb="RUST_TEST_THREADS=1 RUST_GDB=cgdb rust-gdb"
alias rtdb='rustdb $(cargo test -v 2>&1 | grep "Running.*$(pwd)" | cut -f2 -d"\`")'
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")' \
| sk --height 10 \
2017-05-19 17:06:37 +02:00
)"
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'
}