-
Notifications
You must be signed in to change notification settings - Fork 0
/
zshrc
210 lines (173 loc) · 4.73 KB
/
zshrc
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
export FZF_DEFAULT_COMMAND='rg --files --no-ignore-vcs --hidden'
export FZF_DEFAULT_OPTS="-m --height 50%"
export FZF_DEFAULT_OPTS=$FZF_DEFAULT_OPTS" \
--color=bg+:#414559,bg:#303446,spinner:#f2d5cf,hl:#e78284 \
--color=fg:#c6d0f5,header:#e78284,info:#ca9ee6,pointer:#f2d5cf \
--color=marker:#f2d5cf,fg+:#c6d0f5,prompt:#ca9ee6,hl+:#e78284"
export NNN_FIFO=/tmp/nnn.fifo
export NNN_PLUG='f:finder;o:fzopen;p:mocplay;d:diffs;t:nmount;v:imgview'
export NNN_FCOLORS="0B0B04060006060009060B06"
export NNN_TMPFILE="/tmp/lastd"
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export EDITOR="nvim"
export VISUAL="nvim"
export EXA_STRICT=1
export BAT_THEME="base16"
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
export GPG_TTY=$(tty)
# Fix broken escape codes for the man-pages after upgrading from groff-1.22.4-10
# to groff-1.23.0-2. See: https://bbs.archlinux.org/viewtopic.php?id=287185
export GROFF_NO_SGR=1
export PATH="$HOME/.local/bin:$PATH"
export PATH="$HOME/.cargo/bin:$PATH"
export DEBUGINFOD_URLS=""
alias lg="lazygit"
alias hx="helix"
alias zel="zellij options --theme catppuccin-frappe"
alias bat="bat -p"
alias fd="fd --color=never"
alias nnn="nnn -e -U -A"
alias ranger="ranger --choosedir=$HOME/.rangerdir"
alias clc="clear"
alias mkin="sudo make install"
alias msd="meson setup build --buildtype debug"
alias msr="meson setup build --buildtype release"
alias nb="ninja -C build"
alias nc="ninja -C build clean"
alias zsrc="source ~/.zshrc"
alias zedit="$EDITOR ~/.zshrc"
alias todo="$EDITOR ~/todo.md"
alias notes="$EDITOR ~/notes.md"
alias toua="trans :uk "
alias toen="trans uk: "
alias dict="trans -d "
alias gc="git commit"
alias gca="git commit --amend"
alias gs="git status"
alias grv="git remote -v"
alias gba="git branch -a"
alias gck="git checkout"
alias gdiff="git diff"
alias gl="git log"
alias glp="git log -p"
alias gl1="git log --oneline"
alias gshow="git show"
alias gwhat="git log --diff-filter=A --"
alias gbl="git blame"
alias gdp="git diff -p"
alias grh="git reset --hard"
alias grs="git reset --soft"
alias gclc="git clean -fdx"
alias gproff="gdb_profile"
alias genv="get_environment"
if [[ -x $(command -v exa) ]]; then
alias l="exa -l --group-directories-first"
alias ls="exa --group-directories-first"
alias ll="exa -la --group-directories-first"
alias lss="exa -l -s size"
alias lsd="exa -l -s date"
alias lst="exa -l -s size -T"
fi
if [[ -x $(command -v zoxide) ]]; then
alias cd="z"
alias cdi="zi"
eval "$(zoxide init zsh)"
fi
if [[ -x $(command -v nvim) ]]; then
alias vi="nvim"
alias vim="nvim"
fi
ncd() {
# Block nesting of nnn in subshells
if [[ -n $NNNLVL ]] && [[ "${NNNLVL:-0}" -ge 1 ]]; then
echo "nnn is already running"
return
fi
nnn "$@"
if [[ -f "$NNN_TMPFILE" ]]; then
. "$NNN_TMPFILE"
rm -f "$NNN_TMPFILE" > /dev/null
fi
}
rng() {
ranger
if [[ -f $HOME/.rangerdir ]]; then
cd $(cat $HOME/.rangerdir)
fi
}
vif() {
local file=$(fd -t f | fzf)
if [[ -n "$file" ]]; then
${EDITOR:-vim} "$file"
fi
}
cdf() {
local dir=$(fd -I -t d --max-depth 1 | fzf)
if [[ -n $dir ]]; then
cd $dir
fi
}
exf() {
local file=$(fd -t f --max-depth 1| fzf)
local exe_perm=$(ls -la $file | cut -d ' ' -f 1 | grep -o . | sed '4q;d')
if [[ $exe_perm == 'x' ]]; then
./$file
fi
}
is_in_git_repo() {
git rev-parse HEAD > /dev/null 2>&1
}
gvif() {
is_in_git_repo || return
local file=$(git status | grep "modified:" | awk '{print $2}' | fzf);
if [ -n "$file" ]; then
${EDITOR:-vi} "$file"
fi
}
gcf() {
is_in_git_repo || return
local branch=$(git branch --color=always --all --sort=-committerdate |
grep -v HEAD |
fzf --height 50% --ansi --no-multi |
awk '{print $NF}'
)
[[ -z "$branch" ]] && { echo "No branch selected."; return }
if [[ "$branch" =~ ^remotes/ ]]; then
git checkout --track "${branch#remotes/origin/}"
else
git checkout "$branch"
fi
}
gdb_profile() {
nsamples=1
sleeptime=0
pid=$1
echo -e "\nOutput:"
for x in $(seq 1 $nsamples)
do
gdb -ex "set pagination 0" -ex "thread apply all bt" --batch -p $pid
sleep $sleeptime
done | \
awk '
BEGIN { s = ""; }
/^Thread/ { print s; s = ""; }
/^#/ { if (s != "" ) { s = s "," $4} else { s = $4 } }
END { print s }' | \
sort | uniq -c | sort -r -n -k 1,1
}
get_environment() {
if [ -z "$1" ]; then
echo "ERROR: Please provide a PID as an argument."
return 1
fi
cat "/proc/$1/environ" | tr '\0' '\n' | cut -d ':' -f 1-
}
bindkey -v
bindkey -s '^f' 'vif\n'
bindkey -s '^n' 'ncd\n'
bindkey -s '^]' 'cdf\n'
bindkey -s '^v' 'vi .\n'
eval "$(starship init zsh)"
. "$HOME/.cargo/env"