More fully support zsh

Support zshrc, variables, aliases, functions

TODO: incorporate dumping_grounds.zsh into functions.
This commit is contained in:
William Carroll 2019-02-27 17:47:56 +00:00
parent f4c53982c7
commit dba7ac2365
4 changed files with 134 additions and 0 deletions

38
configs/shared/zsh/.zshrc Normal file
View file

@ -0,0 +1,38 @@
source ~/antigen.zsh
# Load the oh-my-zsh library
antigen use oh-my-zsh
# Bundles from robbyrussell's oh-my-zsh repo.
antigen bundle git
antigen bundle alias-tips # friendly reminders to prefer an alias if exists
# antigen bundle common-aliases # be careful with the load order here. Can easily eclipse aliases undesirably
antigen bundle extract # extracts archives polymorphically
antigen bundle zsh-completions # extracts archives polymorphically
# Syntax highlighting
antigen bundle zsh-users/zsh-syntax-highlighting
# Theming
antigen theme robbyrussell
# Leave this last
antigen apply
# Personal Configuration
# Set environment variables for Nix
source /usr/local/google/home/wpcarro/.nix-profile/etc/profile.d/nix.sh
# Configure fzf
source "$(fzf-share)/key-bindings.zsh"
# Configure fasd
eval "$(fasd --init auto)"
# use full path instead of $DOTFILES, since DOTFILES is set herein
DOTFILES="$HOME/programming/dotfiles"
source "$DOTFILES/configs/shared/zsh/variables.zsh"
source "$DOTFILES/configs/shared/zsh/aliases.zsh"
source "$DOTFILES/configs/shared/zsh/functions.zsh"
source "$DOTFILES/configs/shared/zsh/dumping_grounds.zsh"

View file

@ -0,0 +1,57 @@
# These were haphazardly ported from wpcarro/nixify, so some may be broken.
alias pbcopy="xclip -selection clipboard -i"
alias pbpaste="xclip -selection clipboard -o"
alias md="mkdir_cd"
alias ls="exa"
alias ll="exa -l"
alias la="exa -la"
alias lorem="echo Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
alias e="emacsclient --alternate-editor=${EDITOR}"
alias d="docker"
alias dps="docker ps"
alias dpsa="docker ps -a"
alias drm="docker rm"
alias drmi="docker rmi"
alias drit="docker run -it"
alias drd="docker run -d"
alias di="docker images"
alias m="mix"
alias mc="mix compile"
alias mcf="mix compile --force"
alias ism="iex -S mix"
alias tism="MIX_ENV=test iex -S mix"
alias mdg="mix deps.get"
alias mdu="mix deps.update"
alias mdup="mix docker.up"
alias cat="bat"
alias g="git"
alias git="hub"
alias gprom="git pull --rebase origin master"
alias gcan="git commit --amend --no-edit"
alias gpf="git push --force"
alias gpff="git push --force --no-verify"
alias gds="git diff --staged"
alias gfx="git commit --fixup"
alias gsh="git show"
alias gbm="git branch --merged"
alias gwip="git add . && git commit -m wip"
alias gpr="git pull-request"
alias sb="stack build"
alias se="stack exec --"
alias sc="stack clean"
alias st="stack test"
# Currently broken
# alias haddocks=''open "$(stack path --local-doc-root)/index.html"''
alias kc="kubectl"
alias kpods="kubectl get pods"
alias knodes="kubectl get nodes"
alias kdeploys="kubectl get deployments"
alias kdns="kubectl get ing"
alias kedit="kubectl edit deployments "
alias kswitch="gcloud container clusters get-credentials "
alias nq="nix_introspect"
alias nsh="nix-shell"
alias nshp="nix-shell --pure"
alias nr="nix repl"
alias md=mkdir_cd
alias j=z # to emulate autojump; my muscle memory is hardened here

View file

@ -0,0 +1,36 @@
# From Google's ZSH Hacks
# Improvement to fasd's existing `zz` alias
unalias zz
function zz() {
# TODO: Add documentation
local dir
dir="$(fasd -Rdl "$1" | fzf --query="$1" -1 -0 --no-sort +m)" && cd "${dir}" || return 1
}
function fv() {
# Usage: fv file pattern
# This is useful when you know the fuzzy name of the file you want to edit
local file
file="$(fzf --exact --height 40% --reverse --query="$1" --select-1 --exit-0)"
[[ -n "$file" ]] && vim "$file"
}
function bb() {
# Toggle between blaze-bin and your source.
# Useful if you like to cd into the dir where your source lives.
if [[ $PWD =~ '(.*)/blaze-bin(.*)' ]]; then
cd "${match[1]}${match[2]}"
else
cd "${PWD/\/google3//google3/blaze-bin}"
fi
}
function jt() {
# Toggle between the source dir and test dir.
if [[ $PWD =~ '(.*)/javatests(.*)' ]]; then
cd "${match[1]}/java${match[2]}"
else
cd "${PWD/\/google3\/java//google3/javatests}"
fi
}

View file

@ -0,0 +1,3 @@
EDITOR="emacs"
BROWSER="chrome"
NIXIFY="$HOME/programming/nixify"