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
|
|
|
|
|
2020-03-04 12:10:45 +01:00
|
|
|
# arrange history
|
2020-04-15 00:29:26 +02:00
|
|
|
HISTFILE=~/.yash_history
|
2021-01-23 22:42:25 +01:00
|
|
|
HISTSIZE=10000
|
|
|
|
HISTRMDUP=10000
|
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" ; }
|
2017-08-02 10:01:26 +02:00
|
|
|
prompt_git() {
|
2020-08-20 15:52:59 +02:00
|
|
|
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')"
|
2020-12-04 14:39:48 +01:00
|
|
|
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')"
|
2020-08-20 15:52:59 +02:00
|
|
|
local status="$({ echo OK; printf '%s' "$porcelain" | sed '/##/d;s/\(..\).*/\1/'; } | tail -1)"
|
2018-10-22 23:09:42 +02:00
|
|
|
|
2020-08-20 15:52:59 +02:00
|
|
|
echo " (${branch}${behind}${ahead}|${status})"
|
2017-08-02 10:01:26 +02:00
|
|
|
fi
|
|
|
|
}
|
2017-05-19 17:06:37 +02:00
|
|
|
prompt_pwd() {
|
2017-10-20 11:28:10 +02:00
|
|
|
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
|
|
|
|
}
|
2021-03-16 11:37:19 +01:00
|
|
|
prompt_mail() {
|
|
|
|
#unread="$(mpick -t '! seen' | wc -l)"
|
|
|
|
unread="$(mlist -s $(mdirs /data/mail) | wc -l)"
|
|
|
|
[ "$unread" -eq 1 ] && printf ' (1 mail)'
|
|
|
|
[ "$unread" -gt 1 ] && printf ' (%s mails)' "$unread"
|
|
|
|
}
|
2019-08-23 17:18:24 +02:00
|
|
|
BOLD="\fo."
|
|
|
|
GREEN="\fg."
|
|
|
|
RESET="\fD."
|
2021-03-16 11:37:19 +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
|
2020-08-20 15:52:59 +02:00
|
|
|
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
|
|
|
|
2021-03-16 10:47:31 +01:00
|
|
|
# Email
|
|
|
|
alias marchive="mflag -fSt"
|
|
|
|
alias mspam="mflag -fST"
|
|
|
|
alias mkeep="mflag -FSt"
|
|
|
|
|
2018-10-08 13:34:50 +02:00
|
|
|
# There is only one vis
|
2018-06-28 13:53:00 +02:00
|
|
|
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
|
|
|
|
2020-08-20 15:52:59 +02: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
|
|
|
|
2020-08-20 15:52:59 +02:00
|
|
|
# Ledger
|
2020-04-15 00:29:26 +02:00
|
|
|
alias haccounts="hledger -I --alias '/.*:Accounts [^:]*:(.*)/=Accounts:\1' bal accounts"
|
2021-01-23 22:42:25 +01:00
|
|
|
alias ladd='ladd -a /data/documents/ledger/2021/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'
|
2020-03-04 12:10:45 +01:00
|
|
|
|
2020-08-20 15:52:59 +02:00
|
|
|
# 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")' \
|
2020-08-20 15:52:59 +02:00
|
|
|
| sk --height 10 \
|
2017-05-19 17:06:37 +02:00
|
|
|
)"
|
2017-02-09 11:00:03 +01:00
|
|
|
[ -n "$dir" ] && cd "$dir" || false
|
|
|
|
}
|
|
|
|
|
2018-06-28 13:53:00 +02:00
|
|
|
terminfo() {
|
|
|
|
infocmp -x | ssh $@ 'cat > $TERM.info && tic -x $TERM.info && rm $TERM.info'
|
|
|
|
}
|