Skip to content

Instantly share code, notes, and snippets.

@dominic-rossi
Created September 29, 2020 23:19
Show Gist options
  • Save dominic-rossi/fe4f83eec9de533608bb152751f861f7 to your computer and use it in GitHub Desktop.
Save dominic-rossi/fe4f83eec9de533608bb152751f861f7 to your computer and use it in GitHub Desktop.
~/.zshrc
# Luke's config for the Zoomer Shell
# Enable colors and change prompt:
autoload -U colors && colors
PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%m %{$fg[magenta]%}%1~%{$fg[red]%}]%{$reset_color%}$%b "
# History in cache directory:
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.cache/zsh/history
# 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
# 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 {
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
}
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 fff to switch directories and bind it to ctrl-o
lfcd() {
fff "$@"
cd "$(cat "${XDG_CACHE_HOME:=${HOME}/.cache}/fff/.fff_d")"
}
bindkey -s '^o' 'lfcd\n'
# Favourites (Bookmarks) (keys 1-9) (dir or file)
export FFF_FAV1=~/
export FFF_FAV2=~/.zshrc
export FFF_FAV3=~/
export FFF_FAV4=/
export FFF_FAV5=
export FFF_FAV6=
export FFF_FAV7=
export FFF_FAV8=
export FFF_FAV9=
# Edit line in vim with ctrl-e:
autoload edit-command-line; zle -N edit-command-line
bindkey '^e' edit-command-line
# fzf bindings
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# path stuff
export PATH=/usr/local/bin:$PATH
export PATH=$PATH:~/bin/
export PATH="/usr/local/sbin:$PATH"
export PATH="$PATH:~/go/bin/"
# pyenv stuff
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
if which pyenv-virtualenv-init > /dev/null; then
eval "$(pyenv virtualenv-init -)";
fi
# Aliases
# Allow searching by directory using ag and fzf
function ag_search(){
if [ -z "$1" ]; then
ag --nobreak --nonumbers --noheading -f . | fzf
else
ag --nobreak --nonumbers --noheading -f . "$1" | fzf
fi
}
alias agf="ag_search"
alias gco="$HOME/bin/gco.sh"
# PyPI Configuration
export PIP_CONFIG_FILE="~/.pip/pip.conf"
# Setup git completion
export GIT_EDITOR="vim -c'startinsert|norm! ggA'"
# Fix issue with pip installs
alias pip="noglob pip"
# Load zsh-syntax-highlighting; should be last.
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment