autoload -Uz compinit compinit # autocompletion with an arrow-key driven interface zstyle ':completion:*' menu select # create a zkbd compatible hash; # to add other keys to this hash, see: man 5 terminfo typeset -g -A key key[Home]="${terminfo[khome]}" key[End]="${terminfo[kend]}" key[Insert]="${terminfo[kich1]}" key[Backspace]="${terminfo[kbs]}" key[Delete]="${terminfo[kdch1]}" key[Up]="${terminfo[kcuu1]}" key[Down]="${terminfo[kcud1]}" key[Left]="${terminfo[kcub1]}" key[Right]="${terminfo[kcuf1]}" key[PageUp]="${terminfo[kpp]}" key[PageDown]="${terminfo[knp]}" key[Shift-Tab]="${terminfo[kcbt]}" # setup key accordingly [[ -n "${key[Home]}" ]] && bindkey -- "${key[Home]}" beginning-of-line [[ -n "${key[End]}" ]] && bindkey -- "${key[End]}" end-of-line [[ -n "${key[Insert]}" ]] && bindkey -- "${key[Insert]}" overwrite-mode [[ -n "${key[Backspace]}" ]] && bindkey -- "${key[Backspace]}" backward-delete-char [[ -n "${key[Delete]}" ]] && bindkey -- "${key[Delete]}" delete-char [[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-history [[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-history [[ -n "${key[Left]}" ]] && bindkey -- "${key[Left]}" backward-char [[ -n "${key[Right]}" ]] && bindkey -- "${key[Right]}" forward-char [[ -n "${key[PageUp]}" ]] && bindkey -- "${key[PageUp]}" beginning-of-buffer-or-history [[ -n "${key[PageDown]}" ]] && bindkey -- "${key[PageDown]}" end-of-buffer-or-history [[ -n "${key[Shift-Tab]}" ]] && bindkey -- "${key[Shift-Tab]}" reverse-menu-complete # Finally, make sure the terminal is in application mode, when zle is # active. Only then are the values from $terminfo valid. if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then autoload -Uz add-zle-hook-widget function zle_application_mode_start { echoti smkx } function zle_application_mode_stop { echoti rmkx } add-zle-hook-widget -Uz zle-line-init zle_application_mode_start add-zle-hook-widget -Uz zle-line-finish zle_application_mode_stop fi # history search autoload -Uz up-line-or-beginning-search down-line-or-beginning-search zle -N up-line-or-beginning-search zle -N down-line-or-beginning-search [[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-beginning-search [[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-beginning-search # shift, alt, tab and mod modifiers key[Control-Left]="${terminfo[kLFT5]}" key[Control-Right]="${terminfo[kRIT5]}" [[ -n "${key[Control-Left]}" ]] && bindkey -- "${key[Control-Left]}" backward-word [[ -n "${key[Control-Right]}" ]] && bindkey -- "${key[Control-Right]}" forward-word # custom PATH path+=("$HOME"'/.local/bin') path+=("$HOME"'/.cargo/bin') path+=('/user/local/bin') # export to sub-processes (make it inherited by child processes) export PATH export GOPATH=$HOME/.go # fpath if [[ -d "/home/linuxbrew/.linuxbrew/share/zsh/site-functions" ]]; then fpath=(/home/linuxbrew/.linuxbrew/share/zsh/site-functions $fpath) fi # homebrew config if [[ -d "/home/linuxbrew/.linuxbrew/bin/brew" ]]; then eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" fi if command -v brew &> /dev/null; then source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh fi # arch linux zsh extensions if [[ -e "/usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" ]]; then source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh fi if [[ -e "/usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]]; then source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh fi # micromamba if command -v micromamba &> /dev/null; then export MAMBA_EXE=$(which micromamba); export MAMBA_ROOT_PREFIX='~/.micromamba'; __mamba_setup="$("$MAMBA_EXE" shell hook --shell zsh --root-prefix "$MAMBA_ROOT_PREFIX" 2> /dev/null)" if [ $? -eq 0 ]; then eval "$__mamba_setup" else alias micromamba="$MAMBA_EXE" # Fallback on help from mamba activate fi unset __mamba_setup fi # starship config if command -v starship &> /dev/null; then eval "$(starship init zsh)" fi # fnm config if command -v fnm &> /dev/null; then eval "$(fnm env --use-on-cd)" fi # thefuck config fuck() { unfunction fuck eval $(thefuck --alias) fuck "$@" } # yazi config function ya() { local tmp="$(mktemp -t "yazi-cwd.XXXXX")" yazi "$@" --cwd-file="$tmp" if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then cd -- "$cwd" fi rm -f -- "$tmp" } # atuin config if command -v atuin &> /dev/null; then eval "$(atuin init zsh --disable-up-arrow)" fi # zoxide config if command -v zoxide &> /dev/null; then eval "$(zoxide init zsh)" fi # pyenv config if command -v pyenv &> /dev/null; then export PYENV_ROOT="$HOME/.pyenv" [[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init -)" fi # nix config if [ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]; then . $HOME/.nix-profile/etc/profile.d/nix.sh; fi # editors export EDITOR="nvim" export VISUAL="code" # custome alias if command -v eza &> /dev/null; then alias ls=eza alias tree='eza --tree' fi if command -v bat &> /dev/null; then alias cat=bat fi alias f=fuck alias v=nvim alias dotfiles='chezmoi' alias ze='zellij' # micromamba|conda alias alias mm='micromamba' alias ma='micromamba activate' alias mda='micromamba activate base' alias mc='micromamba create' alias mr='micromamba run' alias mi='micromamba install' alias ml='micromamba list' alias me='micromamba env' alias mel='micromamba env list' alias conda='micromamba' # git alias alias g='git' alias ga='git add' alias gb='git branch' alias gc='git commit' alias gcm='git commit -m' alias gcl='git clone --recurse-submodules' alias gl='git pull' alias gp='git push' # distrobox alias alias b='distrobox' alias ba='distrobox enter' alias bls='distrobox ls' # home dir alias i='ya ~/i' {{if eq .chezmoi.os "windows" -}} # windows spec config {{- else if eq .chezmoi.os "linux" -}} {{- if (.chezmoi.kernel.osrelease | lower | contains "microsoft") -}} # wsl spec config alias ssh="ssh.exe" {{- else -}} # linux spec config export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock {{- end -}} {{- end}}