-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot.zshrc.local
98 lines (90 loc) · 2.74 KB
/
dot.zshrc.local
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# -*- shell-script -*-
. ~/.zshrc.from_grml
zstyle :prompt:grml:right:setup use-rprompt false
zstyle :prompt:grml:left:items:percent pre $'\n'
# With upstream grml config, both path and vcs components of the prompt tokens
# always contain a trailing space, so that 'path vcs percent' is separated by
# one space each, but if vcs is empty, there is still only one space between
# path and percent. With the :…:percent pre zstyle above, however, we have a
# newline in between, and the trailing spaces are superfluous—but we still need
# one between path and vcs. Thus, we have no trailing space in path, but a
# leading one in vcs.
function qsx_theme_path() {
emulate -L zsh
if (( !vcscalled )); then
vcs_info
vcscalled=1
fi
# displayed length of $vcs_info_msg_0_,
# cf. https://stackoverflow.com/a/10564427
local zero='%([BSUbfksu]|([FK]|){*})'
local len=${#${(S%%)vcs_info_msg_0_//$~zero/}}
# "%-${len}<": fill the remaining terminal width, but leave room for vcs
REPLY="%-${len}<…<%~%<<"
}
grml_theme_add_token path-qsx -f qsx_theme_path '%B' '%b'
local -a items
if zstyle -a :prompt:grml:left:setup items items; then
# find index of "path"
local i=${items[(i)path]}
# if it exists …
if (( ${+items[$i]} )); then
# … replace with our version …
items[$i]="path-qsx"
# … and apply
zstyle :prompt:grml:left:setup items ${items}
fi
unset i
fi
unset items
function qsx_fix_vcs_info() {
emulate -L zsh
for i in actionformats formats; do
local -a fs
zstyle -a ':vcs_info:*' $i fs || continue
(( ${+fs[1]} )) || continue
# strip trailing space, but add leading
fs[1]=" ${fs[1]% }"
zstyle ':vcs_info:*' $i $fs
done
}
qsx_fix_vcs_info
(( $+commands[bsdtar] )) && alias tar=bsdtar
(( $+commands[nvim] )) && function vim {
command nvim "$@"
# Reset terminal cursor
printf "\033[0 q"
}
if ! (( $+commands[open] )) && (( $+commands[gio] )); then
function open {
gio open "$@" >/dev/null 2>/dev/null
}
fi
alias g=git
alias ec="emacsclient -n"
alias et="emacsclient -t"
alias hl="highlight -O ansi"
if (( $+commands[exa] )); then
alias ls="exa"
alias l="exa -g -l --git"
alias la="exa -g -la --git"
fi
if (( $+commands[eza] )); then
alias ls="eza"
alias l="eza -g -l --git"
alias la="eza -g -la --git"
fi
if (( $+commands[rsync] )); then
alias rs="rsync -vahPi"
fi
gpg-connect-agent /bye
ssh-add -l
function countdown {
ENDTIME=$(date -d "$1" +%s) watch -b -e -n 1 -x sh -c 'DIFF=$(($ENDTIME - $(date +%s))); echo $(($DIFF / 60)) min $(($DIFF % 60)) s; if [ $DIFF -lt 1 ]; then exit 1; fi'
}
function fspass () {
PASSWORD_STORE_DIR=~/RWTH/FSMPI/passwords pass $@
}
function passta () {
PASSWORD_STORE_DIR=~/RWTH/AStA/pass pass $@
}