-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
119 lines (98 loc) · 3.22 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
export PATH="/opt/homebrew/bin:$PATH"
autoload -Uz compinit
compinit
fpath=(~/.zsh $fpath)
zstyle ':completion:*:*:git:*' script ~/.git-completion.bash
# starship
eval "$(starship init zsh)"
export STARSHIP_CONFIG=~/.config/starship/starship.toml
# history setup
HISTFILE=$HOME/.zhistory
SAVEHIST=1000
HISTSIZE=5000
setopt share_history
setopt hist_expire_dups_first
setopt hist_ignore_dups
setopt hist_verify
# completion using arrow keys (based on history)
bindkey "^[[A" history-search-backward
bindkey "^[[B" history-search-forward
# vi mode
bindkey -v
bindkey -M viins 'jk' vi-cmd-mode
# zsh-autosuggestions
source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh
# zsh-syntax-highlighting
source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# fnm
eval "$(fnm env --use-on-cd)"
# aliases
alias bye="rm -rf"
alias cat="bat"
alias cd="z"
alias ga="git add"
alias gaa="git add ."
alias gb="git branch"
alias gbb="git bb"
alias gco="git checkout"
alias gct="git commit"
alias gdf="git diff"
alias gdfs="git diff --staged"
alias gfo="git fetch origin --prune"
alias gl="git log"
alias gll="git log --oneline --decorate --graph"
alias gph="git push"
alias gphf="git push --force-with-lease"
alias gpl="git pull"
alias gre="git restore"
alias gres="git restore --staged"
alias gr="git rebase"
alias gri="git rebase -i"
alias gsh="git stash -u"
alias gshp="git stash pop"
alias gst="git status -u"
alias gsw="git switch"
alias lg="lazygit"
alias ls="eza --color=always --long --git --no-filesize --icons=always --no-time --no-user --no-permissions"
alias pn="pnpm"
alias px="pnpx"
alias tm="tmux"
alias tma="tmux attach"
alias vim="nvim"
# fzf
# Set up fzf key bindings and fuzzy completion
eval "$(fzf --zsh)"
# Use fd instead of fzf
export FZF_DEFAULT_COMMAND="fd --hidden --strip-cwd-prefix --exclude .git"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND="fd --type=d --hidden --strip-cwd-prefix --exclude .git"
# Use fd (https://github.com/sharkdp/fd) for listing path candidates.
# The first argument to the function ($1) is the base path to start traversal
# See the source code (completion.{bash,zsh}) for the details.
_fzf_compgen_path() {
fd --hidden --exclude .git . "$1"
}
# Use fd to generate the list for directory completion
_fzf_compgen_dir() {
fd --type=d --hidden --exclude .git . "$1"
}
show_file_or_dir_preview="if [ -d {} ]; then eza --tree --color=always {} | head -200; else bat -n --color=always --line-range :500 {}; fi"
export FZF_CTRL_T_OPTS="--preview '$show_file_or_dir_preview'"
export FZF_ALT_C_OPTS="--preview 'eza --tree --color=always {} | head -200'"
# Advanced customization of fzf options via _fzf_comprun function
# The first argument to the function is the name of the command.
# You should make sure to pass the rest of the arguments to fzf.
_fzf_comprun() {
local command=$1
shift
case "$command" in
cd) fzf --preview 'eza --tree --color=always {} | head -200' "$@" ;;
export|unset) fzf --preview "eval 'echo ${}'" "$@" ;;
ssh) fzf --preview 'dig {}' "$@" ;;
*) fzf --preview "$show_file_or_dir_preview" "$@" ;;
esac
}
# Bat
export BAT_THEME=kanagawa
# Zoxide
eval "$(zoxide init zsh)"