# Luke's config for the Zoomer Shell # parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' } # Enable colors and change prompt: autoload -U colors && colors # Load colors setopt prompt_subst setopt autocd # Automatically cd into typed directory. stty stop undef # Disable ctrl-s to freeze terminal. setopt interactive_comments autoload -U promptinit promptinit PROMPT="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]\$(parse_git_branch)%{$reset_color%} $%b " # History in cache directory: HISTSIZE=10000000 SAVEHIST=10000000 HISTFILE=~/.cache/zsh/history # Load aliases and shortcuts if existent. # [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc" [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc" # [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" # Basic auto/tab complete: autoload -U compinit zstyle ':completion:*' menu select zmodload zsh/complist compinit _comp_options+=(globdots) # Include hidden files. # vi mode bindkey -v export KEYTIMEOUT=1 # 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' 'ranger_cd\n' bindkey -s '^a' 'bc -lq\n' bindkey -s '^f' 'cd "$(dirname "$(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 # Load syntax highlighting; should be last. source /usr/share/zsh/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh 2>/dev/null alias books="cd $HOME/Documents/books" alias calcurse="calcurse -D ~/.config/calcurse" alias cdgo="cd $HOME/code/go/src/git.jacksontaylor.xyz" alias code="cd $HOME/code" alias dox="cd $HOME/Documents" alias dl="cd $HOME/Downloads" alias gs="git status" alias jojo="cd $HOME/Documents/books/manga/jojos_bizarre_adventure" alias ll="ls -lAh" alias ls="ls -hA --color=auto --group-directories-first" alias music-dl="youtube-dl -x --audio-format mp3 " alias music_info="python3 -m music_tag --print" # alias music="cd $HOME/Music" alias pix="cd $HOME/Pictures" alias ranger="ranger_cd" alias site="cd ~/code/jacksontaylor.xyz" alias up="cd ../" alias vim="nvim" alias vrc="vim ~/.config/nvim/init.vim" alias wiki="nvim +VimwikiIndex" alias diary="nvim +Diary" alias xmpp="$TERMINAL -e profanity" alias wisecow='clear && fortune | cowsay' alias \ cp="cp -iv" \ mv="mv -iv" \ rm="rm -vI" \ bc="bc -ql" \ mkd="mkdir -pv" \ yt="youtube-dl --add-metadata -i" \ yta="yt -x -f bestaudio/best" \ ffmpeg="ffmpeg -hide_banner" alias \ grep="grep --color=auto" \ diff="diff --color=auto" \ ccat="highlight --out-format=ansi" source /usr/share/doc/mcfly/mcfly.zsh # Function to cd to last open dir in ranger ranger_cd() { temp_file="$(mktemp -t "ranger_cd.XXXXXXXXXX")" ranger="${1:-ranger}" if [ -n "$1" ]; then shift fi "$ranger" --choosedir="$temp_file" -- "${@:-$PWD}" return_value="$?" if chosen_dir="$(cat -- "$temp_file")" && [ -n "$chosen_dir" ] && [ "$chosen_dir" != "$PWD" ]; then cd -- "$chosen_dir" fi rm -f -- "$temp_file" return "$return_value" }