-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
275 lines (233 loc) · 7.38 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# Set the directory we want to store zinit and plugins
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
# Download Zinit, if it's not there yet
if [ ! -d "$ZINIT_HOME" ]; then
mkdir -p "$(dirname $ZINIT_HOME)"
git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
fi
# Source/Load zinit
source "${ZINIT_HOME}/zinit.zsh"
# Keybindings
bindkey -e
export KEYTIMEOUT=1
# bindkey '^p' history-search-backward
# bindkey '^n' history-search-forward
# bindkey '^[w' kill-region
bindkey -s ^f "tmux-sessionizer\n"
# Add in zsh plugins
zinit ice depth=1; zinit light romkatv/powerlevel10k
zinit light zsh-users/zsh-syntax-highlighting
zinit light zsh-users/zsh-completions
zinit light zsh-users/zsh-autosuggestions
# Add in snippets
zinit snippet OMZP::sudo
zinit snippet OMZP::archlinux
# zinit snippet OMZP::git
# zinit snippet OMZP::aws
# zinit snippet OMZP::kubectl
# zinit snippet OMZP::kubectx
# zinit snippet OMZP::command-not-found
# Load completions
autoload -Uz compinit && compinit
zinit cdreplay -q
# History
HISTSIZE=5000
HISTFILE=~/.zsh_history
SAVEHIST=$HISTSIZE
HISTDUP=erase
setopt appendhistory
setopt sharehistory
setopt hist_ignore_space
setopt hist_ignore_all_dups
setopt hist_save_no_dups
setopt hist_ignore_dups
setopt hist_find_no_dups
# Completion styling
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
zstyle ':completion:*' menu no
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'ls --color $realpath'
zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview 'ls --color $realpath'
# Select text
if [[ -z "$TMUX" ]]; then
shift-arrow() {
((REGION_ACTIVE)) || zle set-mark-command
zle $1
}
shift-left() shift-arrow backward-char
shift-right() shift-arrow forward-char
shift-up() shift-arrow up-line-or-history
shift-down() shift-arrow down-line-or-history
zle -N shift-left
zle -N shift-right
zle -N shift-up
zle -N shift-down
bindkey $terminfo[kLFT] shift-left
bindkey $terminfo[kRIT] shift-right
bindkey $terminfo[kri] shift-up
bindkey $terminfo[kind] shift-down
fi
# Exports
export EDITOR='nvim'
export LANG='en_US.UTF-8'
export COLORTERM='truecolor'
export FZF_CTRL_R_OPTS="
--preview 'echo {}' --preview-window up:3:hidden:wrap
--bind 'ctrl-/:toggle-preview'
--bind 'ctrl-y:execute-silent(echo -n {2..} | pbcopy)+abort'
--color header:italic
--header 'Press CTRL-Y to copy command into clipboard'"
export FZF_DEFAULT_OPTS="--layout=reverse --inline-info \
--color=bg+:#313244,bg:#1e1e2e,spinner:#f5e0dc,hl:#f38ba8 \
--border=\"rounded\" --border-label="" --preview-window=\"border-rounded\" \
--color=fg:#cdd6f4,header:#f38ba8,info:#cba6f7,pointer:#f5e0dc \
--color=marker:#f5e0dc,fg+:#cdd6f4,prompt:#cba6f7,hl+:#f38ba8"
export FZF_ALT_C_OPTS="
--walker-skip .git,node_modules,target
--preview 'tree -C {}'"
export EZA_COLORS="uu=0:gu=0"
if [ -f ~/.ls_colors ]; then
export LS_COLORS=$(< ~/.ls_colors)
fi
bindkey '\t' autosuggest-accept
bindkey '^I' complete-word
bindkey '^[[Z' autosuggest-accept
# Aliases
alias n='nvim'
alias ff='firefox'
alias nv='neovide'
alias ssha='eval $(ssh-agent) && ssh-add'
alias l='eza -a --icons=auto'
alias ls='eza -lh --icons=auto --color-scale-mode=gradient'
alias lt='eza -T -L 2 --git --git-ignore --icons=auto'
alias ll='eza -lha --icons=auto --sort=name --group-directories-first'
# alias ld='eza -lhD --icons=auto'
alias cat='bat'
alias send='curl -F "file=@$1" 0x0.st'
alias receive='curl -o $1 0x0.st/$1'
alias yls="yadm ls | awk -F/ '{ if (NF==1) {print \$0} else if (!seen[\$1\"/\"\$2]) {print \$1\"/\"\$2\"/\"; seen[\$1\"/\"\$2] = 1} }'"
alias yst="yadm status"
alias cl='calcure 2> /dev/null'
alias bt='bluetoothctl'
# Movement
# Bind Alt+Left to move backward by word
bindkey '^[[1;3D' backward-word
# Bind Alt+Right to move forward by word
bindkey '^[[1;3C' forward-word
# Functions
yup() {
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: yup <file> <commit msg>"
fi
yadm add "$1"
yadm commit -m "$2"
}
t() {
if tmux has-session -t work 2>/dev/null; then
TERM=xterm-256color tmux -u attach-session -t work
else
TERM=xterm-256color tmux -u new-session -s work
fi
}
gpp() {
if [ -z "$1" ]; then
echo "Usage: run_cpp <filename>"
return 1
fi
g++ -std=c++17 -O2 -Wall -Wextra -Wshadow -D_GLIBCXX_DEBUG -DLOCAL -o a.out "$1" && ./a.out
# g++ -std=c++17 -O2 -D_GLIBCXX_DEBUG -DLOCAL -o a.out "$1" && ./a.out
}
# proj() {
# local dir
# dir=$(find ${1:-.} -type d -printf '%p\n' 2> /dev/null | fzf --height 40% --reverse)
# dir=$(realpath "$dir")
# if [[ -n "$dir" ]]; then
# # Launch VS Code and Neovide before tmux
# code "$dir"
# nv "$dir" & > /dev/null 2>&1
# sleep 1
# i3-msg '[class="neovide"] move down'
# i3-msg '[class="Code"] move right'
# if [[ -z "$TMUX" ]]; then
# echo 'HERE'
# t # If not already in a tmux session, create a new one
# fi
# else
# echo "No directory selected."
# fi
# }
rm() {
# Prevent deletion of root and home directories
for arg in "$@"; do
if [ "$arg" = "/" ] || [ "$arg" = "$HOME" ]; then
echo "Error: Attempt to remove root or home directory. Aborting."
return 1
fi
done
# Create Trash directory if it doesn't exist
[ ! -d "$HOME/Trash" ] && mkdir -p "$HOME/Trash"
# Separate options from file/directory names
local files=()
for arg in "$@"; do
if [[ "$arg" != -* ]]; then
files+=("$arg")
fi
done
# Move files and directories to Trash
for file in "${files[@]}"; do
if [ -e "$file" ]; then
mv "$file" "$HOME/Trash/"
else
echo "Warning: '$file' not found."
fi
done
}
proj() {
local dir
dir=$(find "${1:-.}" -type d -printf '%p\n' 2> /dev/null | fzf --height 40% --reverse)
dir=$(realpath "$dir")
if [[ -n "$dir" ]]; then
# Launch VS Code and Neovide before tmux
(code "$dir" &> /dev/null &) &
(nv "$dir" &> /dev/null &) &
# Wait for the windows to appear before moving them
sleep 0.7
# i3-msg '[class="neovide"] move down'
i3-msg '[class="Code"] move right'
if [[ -z "$TMUX" ]]; then
echo 'HERE'
t # If not already in a tmux session, create a new one
fi
tmux send-keys "cd '$dir'" C-m
# clear
else
echo "No directory selected."
fi
}
# Shell integrations
eval "$(fzf --zsh)"
# source <(fzf --zsh)
eval "$(zoxide init --cmd cd zsh)"
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then
exec startx &> /dev/null
fi
export PATH=~/.local/scripts:$PATH
export PATH=~/.local/bin:$PATH
export WORDCHARS=${WORDCHARS//[\/]}
export GIT_TERMINAL_PROMPT=1
# pnpm
export PNPM_HOME="/home/neon/.local/share/pnpm"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esac
# pnpm end
export PATH=/home/neon/.meteor:$PATH