################################################################################ # Basic configuration ################################################################################ setopt BEEP export TERM=alacritty export LANG=en_US.UTF-8 # Disable the log builtin, so we don't conflict with /usr/bin/log disable log # Correctly display UTF-8 with combining characters. if [[ "$(locale LC_CTYPE)" == "UTF-8" ]]; then setopt COMBINING_CHARS fi # Use `nvim` as editor, preferring current instance if nested export EDITOR="${DOTFILES_DIR}/.scripts/nvim_editor.zsh" # Fixes plugin keymap conflicts export ZVM_INIT_MODE=sourcing ################################################################################ # History ################################################################################ HISTFILE=${ZDOTDIR}/.zsh_history HISTSIZE=2147483647 SAVEHIST=$HISTSIZE export HISTORY_IGNORE="(ls|lsd|la|cd|pwd|exit)*" setopt HIST_EXPIRE_DUPS_FIRST setopt HIST_IGNORE_ALL_DUPS setopt HIST_IGNORE_DUPS setopt HIST_IGNORE_SPACE setopt HIST_REDUCE_BLANKS setopt HIST_VERIFY setopt INC_APPEND_HISTORY setopt SHARE_HISTORY ################################################################################ # Prompt ################################################################################ # A pleasant, informative, and transient prompt. Made possible by an arcane # incantation from [powerlevel10k](https://github.com/romkatv/powerlevel10k/), # as described in the project's issue tracker: # https://github.com/romkatv/powerlevel10k/issues/888#issuecomment-657969840 autoload -Uz compinit compinit autoload -Uz vcs_info precmd_vcs_info() { vcs_info } setopt prompt_subst zstyle ':vcs_info:git:*' formats '%F{3}%F{8} %b ' set-long-prompt() { if [ "$NEW_LINE_BEFORE_PROMPT" -eq 1 ]; then print '' else NEW_LINE_BEFORE_PROMPT=1 fi PROMPT='%F{3}%F{8} %d %0(?..%F{3}%F{8} %? )${vcs_info_msg_0_}%F{3}󰒋%F{8} %m %F{3}%F{8} %n %F{3}$ %f%k' } set-short-prompt() { if [[ $PROMPT != '%F{3}$ %f%k' ]]; then PROMPT='%F{3}$ %f%k' zle .reset-prompt fi } precmd_functions=( set-long-prompt precmd_vcs_info ) zle-line-finish() { set-short-prompt } zle -N zle-line-finish trap 'set-short-prompt; return 130' INT ################################################################################ # Potentially interactive execution ################################################################################ # Load SSH key into keychain if [[ $OSTYPE == darwin* ]] then ssh-add --apple-use-keychain $HOME/.ssh/id_rsa >/dev/null 2>&1 else eval `keychain --eval --quiet id_rsa` fi ################################################################################ # Aliases ################################################################################ alias x="exit" alias c="clear && NEW_LINE_BEFORE_PROMPT=0" alias clear="clear && NEW_LINE_BEFORE_PROMPT=0" # nvim if command -v nvim &>/dev/null; then; alias n="nvim" fi; # granted if command -v assume &>/dev/null; then; alias assume=". assume" fi; # docker if command -v docker &>/dev/null; then; alias dockerprune="(docker system prune -a -f && docker system df -v) | less" fi; # git if command -v git &>/dev/null; then; alias g="git" alias gs="git s" alias gl="git l" fi; # lsd if command -v lsd &>/dev/null; then; alias ls="lsd -a" alias la="lsd -la" fi; # lazygit if command -v lazygit &>/dev/null; then; alias lg="lazygit" fi; # lazydocker if command -v lazydocker &>/dev/null; then; alias lg="lazydocker" fi; ################################################################################ # From github.com/zsh-users: # * zsh-autosuggestions # * zsh-syntax-highlighting # Both can be installed through Homebrew. ################################################################################ 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 source $(brew --prefix)/opt/zsh-vi-mode/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh fi ################################################################################ # fzf ################################################################################ if command -v fzf >> /dev/null; then eval "$(fzf --zsh)" fi ################################################################################ # Keybinds ################################################################################ # Ctrl+Y copies buffer to clipboard cmd_to_clip () { pbcopy <<< $BUFFER } zle -N cmd_to_clip bindkey '^Y' cmd_to_clip # Ctrl+G copies git-tracked file contents in directory to the clipboard copy_dir_llm_style () { git ls-files | column; if read -s -q "choice?Total files: $( git ls-files | wc -l) | Press 'y' to copy contents"; then; { echo "Here is the contents of \`$(basename "$PWD")/\`:\n"; git ls-files -z | while IFS= read -r -d $'\0' f; do if [[ "$(file -b --mime-type "$f")" == "text/"* ]]; then echo "$f"; echo '```'; cat "$f"; echo '```'; echo; fi done; } | pbcopy echo "\nCopied!" else; echo "\nQuit without copying anything" fi } zle -N copy_dir_llm_style bindkey '^G' copy_dir_llm_style