configuration/yashrc

106 lines
3.3 KiB
Plaintext
Raw Permalink 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
2021-10-11 09:45:48 +02:00
set --hist-space
HISTFILE=~/.yash_history
2021-10-11 09:45:48 +02:00
HISTSIZE=50000
HISTRMDUP=50000
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
}
2021-03-16 11:37:19 +01:00
prompt_mail() {
2021-04-26 13:43:06 +02:00
unread="$(mlist -nds $(mdirs /data/mail) | wc -l)"
2021-03-16 11:37:19 +01:00
[ "$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
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"
2021-04-26 13:43:06 +02:00
alias munread="mdirs /data/mail | mlist -nds | mseq -S && mscan"
alias minbox="mdirs /data/mail | mlist -ndt | mpick -t 'flagged || ! seen' | msort -d | mthread | mseq -S && mscan | sed 's/^\(...\)\(...\) \(..........\) \(.................\) \(.*\)$/$(tput setaf 119)\1$(tput sgr0)\2 $(tput setaf 8)\3$(tput sgr0) \4 $(tput setaf 148)\5$(tput sgr0)/'"
2021-09-21 21:51:56 +02:00
export MBLAZE_PAGER='less -RF'
2021-03-16 10:47:31 +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"
2021-01-23 22:42:25 +01:00
alias ladd='ladd -a /data/documents/ledger/2021/main.journal /data/documents/ledger/*/main.journal'
2021-09-09 10:19:16 +02:00
alias iadd='iadd /data/documents/ledger/2021/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'
}