-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
133 lines (105 loc) · 4.11 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
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
# NOTE: Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
plugins=(git zsh-autosuggestions zsh-syntax-highlighting web-search)
source $ZSH/oh-my-zsh.sh
# NOTE: User configuration
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
# eval "$(oh-my-posh init zsh --config $HOME/.config/ohmyposh/zen.toml)" # Replace this line with the line below, and remove any other reference to "p10k"
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
# DENO
export DENO_INSTALL="/home/pipo/.deno"
export PATH="$DENO_INSTALL/bin:$PATH"
# pnpm
export PNPM_HOME="/home/pipo/.local/share/pnpm"
export PATH="$PNPM_HOME:$PATH"
# bun completions
[ -s "/home/pipo/.bun/_bun" ] && source "/home/pipo/.bun/_bun"
# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
# NOTE: Nvim Switcher
function nvims() {
items=("default" "Kickstart" "LazyVim")
config=$(printf "%s\n" "${items[@]}" | fzf --prompt=" Neovim Config " --height=50% --layout=reverse --border --exit-0)
if [[ -z $config ]]; then
echo "Nothing selected"
return 0
elif [[ $config == "default" ]]; then
config=""
fi
NVIM_APPNAME=$config nvim $@
}
# NOTE: Lazy Switcher bindkey
bindkey -s ^a "nvims\n"
# NOTE: Starship
eval "$(starship init zsh)"
# NOTE: Bash Aliases
if [[ -f ~/.bash_aliases ]]; then
. ~/.bash_aliases
fi
# NOTE: Bat (better cat) Theme
# sudo apt install bat
# mkdir -p ~/.local/bin
# ln -s /usr/bin/batcat ~/.local/bin/bat
# sudo dpkg -i bat_0.18.3_amd64.deb # adapt version number and architecture
# apk add bat
# NOTE: fzf, install -> "Using git"
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
export FZF_DEFAULT_OPS="--extended"
# -- 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"
}
# PREVIEW
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
}
# NOTE: bat theme
# check "josean page" https://www.josean.com/posts/7-amazing-cli-tools
export BAT_THEME=tokyonight_night
# NOTE: zoxide
eval "$(zoxide init --cmd cd zsh)"
# NOTE: yazi shell wrapper
function yy() {
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")"
yazi "$@" --cwd-file="$tmp"
if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
cd -- "$cwd"
fi
rm -f -- "$tmp"
}
# NOTE: GO path
export PATH=$PATH:/usr/local/go/bin
# NOTE: set Editor
export EDITOR=nvim