-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.zshrc
More file actions
194 lines (161 loc) · 5.61 KB
/
.zshrc
File metadata and controls
194 lines (161 loc) · 5.61 KB
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
# alias
alias ls="eza -A --icons"
alias ll="eza -A --icons -l"
alias lt="eza --tree --icons -A"
alias cat="bat"
alias home="cd ~"
alias c="clear; fastfetch"
alias ora-install='podman run -d --name oracle11g -p 1521:1521 -p 8080:8080 --shm-size=2g --privileged -v oracle_data:/u01/app/oracle docker.io/wnameless/oracle-xe-11g-r2'
alias ora-start='podman start oracle11g'
alias mssql-start='podman start sql1'
alias mssql-stop='podman stop sql1'
alias mssql-sql='podman run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=Systemadmin@123" \
-p 1433:1433 --name sql1 --hostname sql1 \
-d \
mcr.microsoft.com/mssql/server:2022-latest
ddb874fa9af40e4fe401e0f494b85d5f3f54cda2448561783953e961a22b23a2'
alias ora-stop='podman stop oracle11g'
alias ora-sql='podman exec -it oracle11g bash -c "export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe; export PATH=\$ORACLE_HOME/bin:\$PATH; export ORACLE_SID=XE; sqlplus system/oracle"'
alias lj="lazyjj"
# suffix aliases
alias -s md="bat"
alias -s py="$EDITOR"
alias -s json="jless"
alias -s html="open"
# Helpful aliases for zmv
alias zcp='zmv -C' # Copy with patterns
alias zln='zmv -L' # Link with patterns
# Add local binaries to PATH
export PATH="$HOME/.local/bin:$PATH"
export PATH="$HOME/.symfony5/bin:$PATH"
export PATH="$HOME/.cargo/bin:$PATH"
# ~/.zshrc
eval "$(starship init zsh)"
# define default editor
export EDITOR="nvim"
# bun completions
[ -s "/home/yushi_61/.bun/_bun" ] && source "/home/yushi_61/.bun/_bun"
# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
# rg config path
export RIPGREP_CONFIG_PATH="$HOME/.config/.ripgreprc"
### Added by Zinit's installer
if [[ ! -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then
print -P "%F{33} %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f"
command mkdir -p "$HOME/.local/share/zinit" && command chmod g-rwX "$HOME/.local/share/zinit"
command git clone https://github.com/zdharma-continuum/zinit "$HOME/.local/share/zinit/zinit.git" && \
print -P "%F{33} %F{34}Installation successful.%f%b" || \
print -P "%F{160} The clone has failed.%f%b"
fi
source "$HOME/.local/share/zinit/zinit.git/zinit.zsh"
autoload -Uz _zinit
# Enable zmv
autoload -Uz zmv
(( ${+_comps} )) && _comps[zinit]=_zinit
### End of Zinit's installer chunk
#
#Add in zsh plugins
zinit light zsh-users/zsh-syntax-highlighting
zinit light zsh-users/zsh-completions
zinit light zsh-users/zsh-autosuggestions
zinit light Aloxaf/fzf-tab
zinit ice depth=1
zinit light jeffreytse/zsh-vi-mode
zinit load atuinsh/atuin
# Add in snippets
zinit snippet OMZP::sudo
zinit snippet OMZP::archlinux
zinit snippet OMZP::command-not-found
# Autoload completions
autoload -U compinit && compinit
zinit cdreplay -q
# keybindings
# Only changing the escape key to `jk` in insert mode, we still
# keep using the default keybindings `^[` in other modes
ZVM_VI_INSERT_ESCAPE_BINDKEY=jk
# History
HISTSIZE=5000
HISTFILE=~/.zsh_history
SAVEHIST=$HISTSIZE
HISTDUP=erase
# FUNCNEST problem workaround
if [[ "${widgets[zle-keymap-select]#user:}" == "starship_zle-keymap-select" || \
"${widgets[zle-keymap-select]#user:}" == "starship_zle-keymap-select-wrapped" ]]; then
zle -N zle-keymap-select "";
fi
eval "$(starship init zsh)"
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 ':completions:*' menu no
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'ls --color $realpath'
zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview 'ls --color $realpath'
# Shell integrations
eval "$(fzf --zsh)"
eval "$(zoxide init --cmd cd zsh)"
. "$HOME/.atuin/bin/env"
eval "$(atuin init zsh)"
# Create a new Java Maven project folder instantly
makejava() {
mkdir -p "$1/src/main/java/com/school"
cat <<EOF > "$1/pom.xml"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.school</groupId>
<artifactId>$1</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
</project>
EOF
echo "Project $1 created! Code goes in $1/src/main/java/com/school"
}
# open buffer line in editor
bindkey -M vicmd 'v' edit-command-line
# expand history expressions with space
bindkey ' ' magic-space
# To merge hooks, use add-zsh-hook
autoload -Uz add-zsh-hook
# auto enable virtualenv in py projects
function auto_venv() {
# If already in a virtualenv, do nothing
if [[ -n "$VIRTUAL_ENV" && "$PWD" != *"${VIRTUAL_ENV:h}"* ]]; then
deactivate
return
fi
[[ -n "$VIRTUAL_ENV" ]] && return
local dir="$PWD"
while [[ "$dir" != "/" ]]; do
if [[ -f "$dir/.venv/bin/activate" ]]; then
source "$dir/.venv/bin/activate"
return
fi
dir="${dir:h}"
done
}
# list files after cd to a directory
function listfiles_dir() {
ls
}
# Register the hooks
add-zsh-hook chpwd auto_venv
add-zsh-hook chpwd listfiles_dir
# opencode
export PATH=/home/yushi_61/.opencode/bin:$PATH
# Fix Discord Flatpak RPC for Neovim
if [ -d "$XDG_RUNTIME_DIR/app/com.discordapp.Discord" ]; then
ln -sf $XDG_RUNTIME_DIR/app/com.discordapp.Discord/discord-ipc-0 $XDG_RUNTIME_DIR/discord-ipc-0
fi
# dynamic completions for jj
source <(COMPLETE=zsh jj)