From 7888574b1c18c77b75e5c6c5930cd0709f16898a Mon Sep 17 00:00:00 2001 From: Jackson Taylor Date: Thu, 3 Feb 2022 22:22:11 -0500 Subject: Catching up --- .config/zsh/.zshrc | 137 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 102 insertions(+), 35 deletions(-) (limited to '.config/zsh/.zshrc') diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 7f0341f..ca38703 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -1,49 +1,55 @@ # Luke's config for the Zoomer Shell +# +parse_git_branch() { + git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' +} -autoload -U colors && colors -PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~ %{$fg[red]%}] %{$reset_color%}$%b " +# 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 " -source $HOME/.functions +# History in cache directory: +HISTSIZE=10000000 +SAVEHIST=10000000 +HISTFILE=~/.cache/zsh/history # Load aliases and shortcuts if existent. -#[ -f "$HOME/.config/shortcutrc" ] && source "$HOME/.config/shortcutrc" -# [ -f "$HOME/.config/aliasrc" ] && source "$HOME/.config/aliasrc" +# [ -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. -# Include hidden files in autocomplete: -_comp_options+=(globdots) - +# vi mode +bindkey -v export KEYTIMEOUT=1 # Change cursor shape for different vi modes. -function zle-keymap-select { - if [[ ${KEYMAP} == vicmd ]] || - [[ $1 = 'block' ]]; then - echo -ne '\e[1 q' - - elif [[ ${KEYMAP} == main ]] || - [[ ${KEYMAP} == viins ]] || - [[ ${KEYMAP} = '' ]] || - [[ $1 = 'beam' ]]; then - echo -ne '\e[5 q' - fi +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 - -# Use beam shape cursor on startup. -echo -ne '\e[5 q' -# Use beam shape cursor for each new prompt. -preexec() { echo -ne '\e[5 q' ;} +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 () { @@ -51,17 +57,78 @@ lfcd () { lf -last-dir-path="$tmp" "$@" if [ -f "$tmp" ]; then dir="$(cat "$tmp")" - rm -f "$tmp" - if [ -d "$dir" ]; then - if [ "$dir" != "$(pwd)" ]; then - cd "$dir" - fi - fi + rm -f "$tmp" >/dev/null + [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" fi } -bindkey -s '^o' 'lfcd\n' # zsh +bindkey -s '^o' 'ranger_cd\n' + +bindkey -s '^a' 'bc -lq\n' + +bindkey -s '^f' 'cd "$(dirname "$(fzf)")"\n' + +bindkey '^[[P' delete-char -alias vim='nvim' +# Edit line in vim with ctrl-e: +autoload edit-command-line; zle -N edit-command-line +bindkey '^e' edit-command-line -# Load zsh-syntax-highlighting; should be last. -# source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 2>/dev/null +# 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" +} -- cgit v1.2.3