# vim:ft=zsh # ~/.zshrc # ============================================================================ # This is my ZSH configuration. It uses the Starship prompt. There are # lots of things here I borrowed from other places. I need to decide # what features I use and what features I can get rid of. #{{- /* This file supports Go's text/template language. */ -}} # Source the zprofile source $HOME/.zprofile # Source zshenv source $HOME/.zshenv # Enable colors and change prompt: autoload -U colors && colors # Load colors # PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}$%b " setopt autocd # Automatically cd into typed directory. stty stop undef # Disable ctrl-s to freeze terminal. setopt interactive_comments # Add ~/.local/bin to $PATH export PATH="$PATH:$HOME/.local/bin" # Add go binaries to $PATH export PATH="$PATH:$HOME/go/bin" {{ if eq .chezmoi.os "darwin" }} # Add homebrew binaries to path export PATH=$PATH:/opt/homebrew/bin {{ end -}} # Add neovim from Bob to $PATH export PATH="$PATH:$HOME/.local/share/bob/nvim-bin" # Basic auto/tab complete: autoload -U compinit zstyle ':completion:*' menu select zmodload zsh/complist compinit _comp_options+=(globdots) # Include hidden files. # History options export HISTFILE=$HOME/.zsh_history export HISTFILESIZE=1000000000 export HISTSIZE=1000000000 setopt INC_APPEND_HISTORY export HISTTIMEFORMAT="[%F %T] " setopt EXTENDED_HISTORY setopt HIST_FIND_NO_DUPS setopt HIST_IGNORE_ALL_DUPS # vi mode bindkey -v export KEYTIMEOUT=1 # Use vim keys in tab complete menu: bindkey -M menuselect 'h' vi-backward-char bindkey -M menuselect 'k' vi-up-line-or-history bindkey -M menuselect 'l' vi-forward-char bindkey -M menuselect 'j' vi-down-line-or-history bindkey -v '^?' backward-delete-char # Change cursor shape for different vi modes. function zle-keymap-select () { case $KEYMAP in vicmd) echo -ne '\e[1 q';; # block viins|main) echo -ne '\e[5 q';; # beam esac } zle -N zle-keymap-select zle-line-init() { zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere) echo -ne "\e[5 q" } zle -N zle-line-init echo -ne '\e[5 q' # Use beam shape cursor on startup. preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt. # Use lf to switch directories and bind it to ctrl-o lfcd () { tmp="$(mktemp)" lf -last-dir-path="$tmp" "$@" if [ -f "$tmp" ]; then dir="$(cat "$tmp")" rm -f "$tmp" >/dev/null [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" fi } bindkey -s '^o' 'lfcd\n' bindkey -s '^a' 'bc -lq\n' bindkey -s '^f' '$(eval find $HOME/.config $HOME/code $HOME/.local/share -mindepth 1 -maxdepth 1 | fzf)\n' bindkey '^[[P' delete-char # Edit line in vim with ctrl-e: autoload edit-command-line; zle -N edit-command-line bindkey '^e' edit-command-line ### ALIASES ### # Use neovim for vim if present. [ -x "$(command -v nvim)" ] && alias vim="nvim" vimdiff="nvim -d" # Verbosity and settings that you pretty much just always are going to want. alias \ cp="cp -iv" \ mv="mv -iv" \ rm="rm -vI" \ bc="bc -ql" \ mkd="mkdir -pv" \ ffmpeg="ffmpeg -hide_banner" # Colorize commands when possible. alias \ ls="ls -hN --color=auto --group-directories-first" \ grep="grep --color=auto" \ diff="diff --color=auto" \ ip="ip -color=auto" # These common commands are just too long! Abbreviate them. alias \ ka="killall" \ g="git" \ e="$EDITOR" \ v="$EDITOR" \ # Changing "ls" to "eza" alias ls='eza -al --color=always --group-directories-first' # my preferred listing alias la='eza -a --color=always --group-directories-first' # all files and dirs alias ll='eza -l --color=always --group-directories-first' # long format alias lt='eza -aT --color=always --group-directories-first' # tree listing alias l.='eza -a | egrep "^\."' # Pomodoro timers (credit to https://gist.github.com/bashbunni/3880e4194e3f800c4c494de286ebc1d7) declare -A pomo_options pomo_options["work"]="20" pomo_options["break"]="5" pomodoro () { if [ -n "$1" -a -n "${pomo_options["$1"]}" ]; then val=$1 echo $val | lolcat timer ${pomo_options["$val"]}m spd-say "'$val' session done" fi } alias wo="pomodoro 'work'" alias br="pomodoro 'break'" # Kill Kodi with one command alias killkodi="kill -9 `ps aux | grep '/usr/lib/x86_64-linux-gnu/kodi/kodi.bin' -m 1 | tr -s ' ' | cut -d ' ' -f 2`" # Edit a file with Chezmoi and apply it immediately alias ce='chezmoi edit --apply' # Enter the ~/.local/share/chezmoi directory faster alias cdc='$HOME/.local/share/chezmoi/' # Shortcut for sourcing this file alias zource='source $HOME/.zshrc' # Poetry run Neovim alias pn='poetry run nvim .' # Load Starship eval "$(starship init zsh)" {{ if eq .chezmoi.os "linux" }} # Load zoxide eval "$(zoxide init zsh)" {{ end -}}