You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

176 lines
6.5 KiB

8 months ago
# Personal Zsh configuration file. It is strongly recommended to keep all
# shell customization and configuration (including exported environment
# variables such as PATH) in this file or in files sourced from it.
#
# Documentation: https://github.com/romkatv/zsh4humans/blob/v5/README.md.
[ -z "$ZPROF" ] || zmodload zsh/zprof
# Periodic auto-update on Zsh startup: 'ask' or 'no'.
# You can manually run `z4h update` to update everything.
zstyle ':z4h:' auto-update 'ask'
# Ask whether to auto-update this often; has no effect if auto-update is 'no'.
zstyle ':z4h:' auto-update-days '7'
# Keyboard type: 'mac' or 'pc'.
zstyle ':z4h:bindkey' keyboard 'mac'
# Don't start tmux.
zstyle ':z4h:' start-tmux 'yes'
# Mark up shell's output with semantic information.
zstyle ':z4h:' term-shell-integration 'yes'
zstyle ':z4h:' prompt-at-bottom 'yes'
# Right-arrow key accepts one character ('partial-accept') from
# command autosuggestions or the whole thing ('accept')?
zstyle ':z4h:autosuggestions' forward-char 'accept'
# Recursively traverse directories when TAB-completing files.
zstyle ':z4h:fzf-complete' recurse-dirs 'yes'
8 months ago
zstyle ':z4h:fzf-complete' fzf-bindings tab:repeat
8 months ago
# Enable direnv to automatically source .envrc files.
zstyle ':z4h:direnv' enable 'yes'
# Show "loading" and "unloading" notifications from direnv.
zstyle ':z4h:direnv:success' notify 'yes'
# Enable ('yes') or disable ('no') automatic teleportation of z4h over
# SSH when connecting to these hosts.
8 months ago
# zstyle ':z4h:ssh:example-hostname1' enable 'yes'
# zstyle ':z4h:ssh:*.example-hostname2' enable 'no'
8 months ago
# The default value if none of the overrides above match the hostname.
zstyle ':z4h:ssh:*' enable 'no'
8 months ago
zstyle ':completion:*:ssh:argument-1:' tag-order hosts users
zstyle ':completion:*:scp:argument-rest:' tag-order hosts files users
zstyle ':completion:*:(ssh|scp|rdp):*:hosts' hosts
zstyle ':z4h:term-title:ssh' preexec '%n@'${${${Z4H_SSH##*:}//\%/%%}:-%m}': ${1//\%/%%}'
zstyle ':z4h:term-title:ssh' precmd '%n@'${${${Z4H_SSH##*:}//\%/%%}:-%m}': %~'
# https://github.com/romkatv/zsh4humans/issues/53#issuecomment-706493865
zstyle ':zle:up-line-or-beginning-search' leave-cursor false
zstyle ':zle:down-line-or-beginning-search' leave-cursor false
8 months ago
# Send these files over to the remote host when connecting over SSH to the
# enabled hosts.
# zstyle ':z4h:ssh:*' send-extra-files '~/.nanorc' '~/.env.zsh'
# Clone additional Git repositories from GitHub.
#
# This doesn't do anything apart from cloning the repository and keeping it
# up-to-date. Cloned files can be used after `z4h init`. This is just an
# example. If you don't plan to use Oh My Zsh, delete this line.
# z4h install ohmyzsh/ohmyzsh || return
# Install or update core components (fzf, zsh-autosuggestions, etc.) and
# initialize Zsh. After this point console I/O is unavailable until Zsh
# is fully initialized. Everything that requires user interaction or can
# perform network I/O must be done above. Everything else is best done below.
z4h init || return
# Extend PATH.
8 months ago
path=(
~/bin
$path
)
8 months ago
# Export environment variables.
export GPG_TTY=$TTY
8 months ago
8 months ago
export EDITOR=nvim
export VISUAL=nvim
8 months ago
8 months ago
export BAT_THEME=ashes
export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --border"
export FZF_DEFAULT_COMMAND="fd --type f --strip-cwd-prefix --hidden --follow --exclude .git"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND="fd --type d --strip-cwd-prefix --hidden --follow --exclude .git"
8 months ago
8 months ago
export RUBY_YJIT_ENABLE=true
8 months ago
# Source additional local files if they exist.
8 months ago
if (( $+commands[fzf] )); then
[[ $- == *i* ]] && z4h source ${HOMEBREW_PREFIX:+$HOMEBREW_PREFIX/opt/fzf/shell/completion.zsh}
fi
8 months ago
z4h source ${HOMEBREW_PREFIX:+$HOMEBREW_PREFIX/opt/chruby/share/chruby/chruby.sh}
8 months ago
z4h source ~/.dotfiles/src/fzf-git.sh/fzf-git.sh
8 months ago
z4h source ~/.local.zsh
8 months ago
# Use additional Git repositories pulled in with `z4h install`.
#
# This is just an example that you should delete. It does nothing useful.
# z4h source ohmyzsh/ohmyzsh/lib/diagnostics.zsh # source an individual file
# z4h load ohmyzsh/ohmyzsh/plugins/emoji-clock # load a plugin
# Define key bindings.
z4h bindkey undo Ctrl+/ Shift+Tab # undo the last command line change
z4h bindkey redo Option+/ # redo the last undone command line change
z4h bindkey z4h-cd-back Shift+Left # cd into the previous directory
z4h bindkey z4h-cd-forward Shift+Right # cd into the next directory
z4h bindkey z4h-cd-up Shift+Up # cd into the parent directory
z4h bindkey z4h-cd-down Shift+Down # cd into a child directory
# Both using `z4h bindkey` instead of just `bindkey` and `^` instead of `\e`
# results in the cursor staying at the beginning of the command.
bindkey "\ep" history-beginning-search-backward
bindkey "\en" history-beginning-search-forward
bindkey " " magic-space
8 months ago
if (( $+commands[fzf] )); then
z4h source ${HOMEBREW_PREFIX:+$HOMEBREW_PREFIX/opt/fzf/shell/key-bindings.zsh}
# Not sure how to do key sequences w/`z4h bindkey`
bindkey '^gg' fzf-git-branches-widget
# ^gl doesn't work in tmux, but I need reflogs more than remotes probably?
bindkey '^gr' fzf-git-lreflogs-widget
# https://github.com/junegunn/fzf/issues/164#issuecomment-581837757
z4h bindkey fzf-cd-widget ç
fi
8 months ago
# Autoload functions.
autoload -Uz zmv
# Define functions and completions.
function md() { [[ $# == 1 ]] && mkdir -p -- "$1" && cd -- "$1" }
compdef _directories md
8 months ago
# https://docs.brew.sh/Shell-Completion
if type brew &>/dev/null; then
FPATH=${HOMEBREW_PREFIX:+$HOMEBREW_PREFIX/share/zsh/site-functions:${FPATH}}
autoload -Uz compinit
compinit
fi
8 months ago
# Define named directories: ~w <=> Windows home directory on WSL.
# [[ -z $z4h_win_home ]] || hash -d w=$z4h_win_home
# Define aliases.
alias clear=z4h-clear-screen-soft-bottom
8 months ago
(( $+commands[eza] )) && alias ls=eza
8 months ago
alias rake='noglob rake' # don't match on square brackets
alias tat='tmux new-session -As `basename $PWD | ruby -e "puts ARGF.read.strip.downcase.gsub(/[^\w]+/, ?-)"`'
alias tree='tree -a -I .git'
# Add flags to existing aliases.
8 months ago
alias ls="${aliases[ls]:-ls} -A"
8 months ago
# Set shell options: http://zsh.sourceforge.net/Doc/Release/Options.html.
setopt glob_dots # no special treatment for file names with a leading dot
setopt auto_menu # require an extra TAB press to open the completion menu
# https://github.com/romkatv/zsh4humans/issues/110#issuecomment-846824056
[[ ! -v functions[command_not_found_handler] ]] || unfunction command_not_found_handler
8 months ago
# default to ruby 3.3
which chruby &>/dev/null && chruby 3.3
8 months ago
[ -z "$ZPROF" ] || zprof