-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
163 lines (127 loc) · 4.83 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
stty stop undef # Disable Ctrl-s to freeze terminal (must be above p10k instant prompt)
# 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
source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
wintitle() { echo -ne "\033];$TERMINAL: $(pwd) \007" }
precmd_functions+=(wintitle)
setname() { i3-msg title_format "$@" }
setnamep() { i3-msg focus parent, title_format "$@", focus child }
# Zsh options
setopt autocd
setopt interactive_comments
setopt no_auto_remove_slash
# History in cache directory
HISTSIZE=10000000
SAVEHIST=10000000
HISTFILE=~/.cache/zsh/history
# Basic auto/tab complete
autoload -Uz compinit
zstyle ':completion:*' menu select
zmodload zsh/complist
compinit
_comp_options+=(globdots) # include hidden files
setopt magicequalsubst
export TERMINAL=kitty
export EDITOR=vim
# vi-mode
bindkey -v
KEYTIMEOUT=5
bindkey -v '^?' backward-delete-char # fix backspace deletion after re-entering insert mode
# hjkl autocomplete menu select
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'k' vi-up-line-or-history
bindkey -M menuselect 'l' vi-forward-char
bindkey -M menuselect 'j' vi-down-line-or-history
# Edit line in vim with Ctrl-e
autoload edit-command-line
zle -N edit-command-line
bindkey '^e' edit-command-line
[ -f "/usr/share/zsh/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh" ] && source /usr/share/zsh/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
[ -f "/usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" ] && source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
bindkey '^f' autosuggest-accept
# fzf
export FZF_DEFAULT_COMMAND='fd --hidden --follow --exclude ".git"' # use with fd instead of find
[ -f "/usr/share/fzf/key-bindings.zsh" ] && source /usr/share/fzf/key-bindings.zsh
[ -f "/usr/share/fzf/completion.zsh" ] && source /usr/share/fzf/completion.zsh
[ -d "~/.cargo/bin" ] && PATH=$PATH:~/.cargo/bin
PATH=$PATH:~/.local/bin
# Disable dotnet telemetry
export DOTNET_CLI_TELEMETRY_OPTOUT=1
# Aliases
alias sudo='sudo ' # check 2nd word for alias as well
alias ls='ls --color=auto'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias ll='ls -alhFv --color=auto --group-directories-first'
alias la='ls -Av'
alias l='ls -CFv'
alias fd='fd --hidden'
alias bc='bc -lq'
alias ssh='TERM=vt100 ssh' # kitty terminfo is different, use vt100 for SSH for maximum compatibility
alias rsyncnoperm="rsync -azPZ"
alias cleandisk='yay -Sc && paccache -rk1 && sudo trash-empty --all-users'
alias sysinfo='echo "" && neofetch'
alias weather='curl http://wttr.in/Lenart'
alias vm='sudo ~/dotfiles/vm/win-pci.sh'
alias ptt='sudo python ~/dotfiles/lib/ptt.py'
alias vcam="sudo modprobe v4l2loopback exclusive_caps=1 card_label='OBS Virtual Camera'"
alias vcamrm="sudo modprobe -r v4l2loopback"
alias matlab='matlab -desktop -nosplash -useStartupFolderPref'
alias fsmaps='ranger ~/Work/TARGET/Mappings'
# Signal on yay exit (i3block)
yay() {
command yay "$@" &&
pkill -RTMIN+4 i3status-rs
}
# GPU Offload
gpu() {
DRI_PRIME=1 "$@" # PRIME
}
alias obs='vk_pro obs' # AMD AMF (hardware encoder) with AMDGPU PRO
# Require virtualenv for pip
export PIP_REQUIRE_VIRTUALENV=true
pip-global() {
PIP_REQUIRE_VIRTUALENV=false pip "$@"
}
# init-vm.sh is slow, only init on request
if [ -f /usr/share/nvm/init-nvm.sh ]; then
alias nvminit='. /usr/share/nvm/init-nvm.sh'
fi
# Bind fg for switching between vim and terminal (C-z / C-z) if interactive shell
if [[ "$-" =~ "i" ]]; then
function fgswitch { fg }
zle -N fgswitch
bindkey '^Z' fgswitch
fi
# https://github.com/gujiaxi/ranger-cd/blob/master/ranger-cd.zsh
function ranger-cd {
tempfile="$(mktemp -t tmp.XXXXXX)"
/usr/bin/ranger --choosedir="$tempfile" "${@:-$(pwd)}"
test -f "$tempfile" &&
if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
cd -- "$(cat "$tempfile")"
fi
rm -f -- "$tempfile"
}
bindkey -s '^O' 'ranger-cd\n'
# Jump to path and synchronization aliases
__base_school='~/Work/School/FERI-RIT'
alias jL='cd ~/Work/Linux'
alias jS="cd $__base_school"
alias jSP="cd $__base_school/Projects/MAG"
alias jSF="cd $__base_school/Theses/MAG"
alias jA3='cd ~/Work/Arma\ 3'
alias jA3M='cd ~/Work/Arma\ 3/Mods'
alias jA3T='cd ~/Work/Arma\ 3/Tools'
alias jIDI='cd ~/Work/IDI'
if [ $(hostname) = "odin" ]; then
alias vm='sudo ~/dotfiles/vm/win-gvt.sh'
fi