Created
July 6, 2023 13:02
-
-
Save Hubro/d6d9a2dc20f540beaaed72e3075b80f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vim: fdm=marker:fdl=0 | |
[[ -f "$HOME/.zprofile" ]] && source "$HOME/.zprofile" | |
# {{{ ZSH general config | |
HISTFILE=~/.histfile | |
HISTSIZE=10000 | |
SAVEHIST=10000 | |
KEYTIMEOUT=1 | |
WORDCHARS='*?_-.[]~=&;!#$%^(){}<>' | |
setopt SHARE_HISTORY nomatch notify | |
#bindkey '^R' history-incremental-search-backward | |
# }}} | |
# {{{ ZSH completion config | |
fpath=(~/Dropbox/Config/zsh-completions $fpath) | |
zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate | |
zstyle ':completion:*' max-errors 2 | |
zstyle :compinstall filename '/home/tomas/.zshrc' | |
autoload -Uz compinit | |
compinit | |
autoload -U +X bashcompinit && bashcompinit | |
complete -o nospace -C /usr/bin/tk tk | |
# }}} | |
# {{{ Antigen plugin manager | |
# | |
# This block of config works automatically with the "antigen-git" AUR package | |
# on Arch and with the "antigen" homebrew package on macOS. | |
# | |
# Possible init script locations | |
ANTIGEN_INIT_SCRIPT=( | |
"/usr/share/zsh/share/antigen.zsh" | |
"/usr/share/zsh-antigen/antigen.zsh" | |
"/usr/local/share/antigen/antigen.zsh" | |
) | |
for ANTIGEN_INIT_SCRIPT_PATH in "${ANTIGEN_INIT_SCRIPT[@]}"; do | |
if [[ -f "$ANTIGEN_INIT_SCRIPT_PATH" ]]; then | |
source "$ANTIGEN_INIT_SCRIPT_PATH" | |
antigen bundle jeffreytse/zsh-vi-mode | |
antigen bundle rupa/z | |
antigen apply | |
# Configure zsh-vi-mode | |
zvm_after_init_commands+=('__apply_keybindings') | |
ZVM_INSERT_MODE_CURSOR=$ZVM_CURSOR_BLINKING_BEAM | |
ZVM_NORMAL_MODE_CURSOR=$ZVM_CURSOR_BLOCK | |
ZVM_LINE_INIT_MODE=$ZVM_MODE_INSERT | |
ZVM_CURSOR_STYLE_ENABLED=true | |
#ZVM_INSERT_MODE_CURSOR=$ZVM_CURSOR_BLINKING_BLOCK | |
#ZVM_NORMAL_MODE_CURSOR=$ZVM_CURSOR_BLOCK | |
break | |
fi | |
done | |
unset ANTIGEN_INIT_SCRIPT | |
unset ANTIGEN_INIT_SCRIPT_PATH | |
function __apply_keybindings() { | |
# Re-applies FZF keybindings | |
if [[ -f "/usr/share/fzf/key-bindings.zsh" ]]; then | |
source "/usr/share/fzf/key-bindings.zsh" | |
elif [[ -f "/usr/local/Cellar/fzf/0.39.0/shell/key-bindings.zsh" ]]; then | |
source "/usr/local/Cellar/fzf/0.39.0/shell/key-bindings.zsh" | |
fi | |
zvm_define_widget __up_one_dir | |
zvm_bindkey viins '^U' __up_one_dir | |
} | |
# ZVM widget to go up one directory (cd ..) | |
function __up_one_dir() { | |
BUFFER="cd .." | |
zle accept-line | |
} | |
# Executed automatically by zsh-vi-mode for setting up keybindings | |
function zvm_after_lazy_keybindings() { | |
} | |
# }}} | |
# {{{ FZF | |
#export FZF_DEFAULT_OPTS="--height 50% --reverse --border --preview 'bat -p --color=always {}'" | |
export FZF_DEFAULT_OPTS="--height 50% --reverse --border" | |
export FZF_CTRL_R_OPTS="--height 10 --layout=default" | |
# By default, show all files except: | |
# - Files in hidden directories (like .git/) | |
# - Python cache files | |
# - Node modules | |
export FZF_DEFAULT_COMMAND=' | |
find . -type f,l \ | |
! -path "*/.*/*" \ | |
! -path "*/__pycache__/*" \ | |
! -path "*/node_modules/*"' | |
# Default FZF keybindings | |
if [[ -f "/usr/share/fzf/key-bindings.zsh" ]]; then | |
source "/usr/share/fzf/key-bindings.zsh" | |
elif [[ -f "/usr/local/Cellar/fzf/0.39.0/shell/key-bindings.zsh" ]]; then | |
source "/usr/local/Cellar/fzf/0.39.0/shell/key-bindings.zsh" | |
fi | |
# Default FZF completions | |
if [[ -f "/usr/share/fzf/completion.zsh" ]]; then | |
source "/usr/share/fzf/completion.zsh" | |
elif [[ -f "/usr/local/Cellar/fzf/0.39.0/shell/completion.zsh" ]]; then | |
source "/usr/local/Cellar/fzf/0.39.0/shell/completion.zsh" | |
fi | |
# }}} | |
# {{{ Kubectl completion | |
#if which kubectl &>/dev/null; then | |
# eval "$(kubectl completion zsh 2>/dev/null)" | |
#fi | |
# }}} | |
# {{{ gcloud cli completion | |
GCLOUD_COMPLETION="/opt/google-cloud-sdk/completion.zsh.inc" | |
[[ -f "$GCLOUD_COMPLETION" ]] && source "$GCLOUD_COMPLETION" | |
# }}} | |
# {{{ Shell init script | |
SHELL_SETUP="$HOME/Cloud/Config/shell-setup.zsh" | |
[[ -f "$SHELL_SETUP" ]] && source "$SHELL_SETUP" | |
unset SHELL_SETUP | |
# }}} | |
# {{{ Nix | |
if on-arch; then | |
export PATH="$HOME/.nix-profile/bin:$PATH" | |
export NIX_PATH="$HOME/.nix-defexpr/channels/stable" | |
fi | |
# }}} | |
# {{{ Pyenv | |
if which pyenv &>/dev/null; then | |
# The relevant environment variables are set in .zprofile | |
eval "$(pyenv init - --no-rehash)" | |
eval "$(pyenv virtualenv-init - --no-rehash)" | |
if [[ $(uname) == "Linux" ]]; then | |
autoload _pyenv; _pyenv # Completions | |
fi | |
fi | |
# }}} | |
# {{{ NVM (Node Version Manager) | |
# Let's try just using Nix instead! :D | |
# NVM_DIR="$HOME/.nvm" | |
# | |
# # Arch Linux | |
# NVM_INIT_SCRIPT="/usr/share/nvm/init-nvm.sh" | |
# if [[ -f "$NVM_INIT_SCRIPT" ]]; then | |
# source "$NVM_INIT_SCRIPT" --no-use | |
# #source "$NVM_INIT_SCRIPT" | |
# fi | |
# | |
# # MacOS | |
# NVM_INIT_SCRIPT="/usr/local/opt/nvm/nvm.sh" | |
# if [[ -f "$NVM_INIT_SCRIPT" ]]; then | |
# source "$NVM_INIT_SCRIPT" --no-use | |
# #source "$NVM_INIT_SCRIPT" | |
# fi | |
# | |
# unset NVM_INIT_SCRIPT | |
# }}} | |
# {{{ fnm (Node version manager written in Rush) | |
if which fnm &>/dev/null; then | |
eval "$(fnm env --use-on-cd)" | |
fi | |
# }}} | |
# {{{ Starship | |
if which starship &>/dev/null; then | |
eval "$(starship init zsh)" | |
fi | |
# }}} | |
# {{{ Direnv (https://direnv.net/) | |
if which direnv &>/dev/null; then | |
export DIRENV_LOG_FORMAT= | |
eval "$(direnv hook zsh)" | |
fi | |
# }}} | |
# {{{ Broot | |
if which broot &>/dev/null; then | |
eval "$(broot --print-shell-function zsh)" | |
fi | |
# }}} | |
# {{{ Syntax highlighting | |
SYNTAX_HIGHLIGHTING_INIT="/usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" | |
if [[ -f "$SYNTAX_HIGHLIGHTING_INIT" ]]; then | |
source "$SYNTAX_HIGHLIGHTING_INIT" | |
fi | |
# }}} | |
# {{{ Allow parent to initialize shell | |
# | |
# This is awesome for opening embedded terminals in VSCode or Neovim. | |
# | |
if [[ -n $ZSH_INIT_COMMAND ]]; then | |
echo "Running: $ZSH_INIT_COMMAND" | |
eval "$ZSH_INIT_COMMAND" | |
fi | |
# }}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment