diff options
author | William Carroll <wpcarro@gmail.com> | 2019-10-09T11·13+0100 |
---|---|---|
committer | William Carroll <wpcarro@gmail.com> | 2019-12-24T15·21+0000 |
commit | 6b456c1b7a4f6899f063a6e65355af51901d9c7a (patch) | |
tree | cfc70d74818ae9fabdbbfb0cf16cce092e4c1a09 /configs/shared/.zshrc | |
parent | a7c72adb2ebec1e497fc040eaf3551d564d61a5b (diff) |
Massive configuration overhaul
Currently paying the price of months of non-diligent git usage. Here's what has changed. - Theming support in Gvcci and wpgtk - Dropping support for i3 - Supporting EXWM - Many Elisp modules - Collapsed redundant directories in ./configs
Diffstat (limited to 'configs/shared/.zshrc')
-rw-r--r-- | configs/shared/.zshrc | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/configs/shared/.zshrc b/configs/shared/.zshrc new file mode 100644 index 000000000000..0783f35529fd --- /dev/null +++ b/configs/shared/.zshrc @@ -0,0 +1,100 @@ +# Necessary to add this line and keep it at the top of my ~/.zshrc to ensure +# that Tramp works as expected. This was taken from here: +# https://www.emacswiki.org/emacs/TrampMode +[[ $TERM == "dumb" ]] && unsetopt zle && PS1='$ ' && return + +source ~/antigen.zsh + +# Helper functions +# TODO: Find a way to share these functions across zsh files. +defensively_source() { + # Checks if the file exists before sourcing it + if [ -f $1 ]; then + source $1 + else + "Cannot source: $1. Aborting..." + fi +} + +command_exists() { + # Predicate to check if the command exists + command -v $1 >/dev/null +} + +# TODO: remove this from here +export DOTFILES=$HOME/Dropbox/dotfiles + +# Load the oh-my-zsh library +antigen use oh-my-zsh + +# Bundles from robbyrussell's oh-my-zsh repo. +antigen bundle git +antigen bundle extract # extracts archives polymorphically +antigen bundle zsh-completions # extracts archives polymorphically + +# Syntax highlighting +antigen bundle zsh-users/zsh-syntax-highlighting + +# Theming +case $(hostname) in + # desktop + wpcarro.lon.corp.google.com) + antigen theme frisk;; + # cloudtop + wpcarro.c.googlers.com) + antigen theme cloud;; + # laptop + wpcarro2) + antigen theme refined;; + # acer NixOS laptop + acer-manjaro) + antigen theme frisk;; +esac + +# Leave this last +antigen apply + +# Configure fzf +if command_exists fzf-share; then + source "$(fzf-share)/key-bindings.zsh" + + fzf-locate-widget() { + # Press M-i to search entire locate database with fzf. + local selected + if selected=$(locate / | fzf); then + LBUFFER+=$selected + fi + zle redisplay + } + zle -N fzf-locate-widget + bindkey '\ei' fzf-locate-widget + +else + defensively_source "/usr/share/fzf/key-bindings.zsh" +fi + +# Configure fasd +eval "$(fasd --init auto)" + +# the above line slows tab-completion down dramatically because it attemtps to +# autocomplete for the 600k+ users found in `compgen -u`. Below is a fix which +# also restores the function of `cd ~<tab>` to display only ZSH Named +# Directories. +zstyle ':completion:*' users root $USER + +# Avoiding the defensive source because I want to ensure these files are +# available. +source "$DOTFILES/configs/shared/variables.zsh" +source "$DOTFILES/configs/shared/aliases.zsh" +source "$DOTFILES/configs/shared/functions.zsh" +source "$DOTFILES/configs/shared/zle.zsh" + +preexec() { + # `preexec` runs before every command is run. + update_x11_forwarding +} + +defensively_source ~/.rvm/scripts/rvm # Ruby +defensively_source ~/.opam/opam-init/init.zsh # OCaml +defensively_source ~/.ghcup/env # Haskell +defensively_source /etc/bash_completion.d/g4d # Google's g4d |