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
|
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" ; }
|
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
|
|
|
|
}
|
|
|
|
BOLD="\fo."
|
|
|
|
GREEN="\fg."
|
|
|
|
RESET="\fD."
|
2020-12-04 14:39:48 +01:00
|
|
|
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
|
2020-08-20 15:52:59 +02:00
|
|
|
# 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
|
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"
|
|
|
|
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'
|
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'
|
|
|
|
}
|