Skip to content

Instantly share code, notes, and snippets.

@j0ni
Last active June 2, 2016 00:36
Show Gist options
  • Save j0ni/4138656 to your computer and use it in GitHub Desktop.
Save j0ni/4138656 to your computer and use it in GitHub Desktop.
Some zsh setup
# list possibles on first completion attempt
setopt AUTO_LIST
# cycle through the choices after that
setopt AUTO_MENU
# keep timestamps
setopt EXTENDED_HISTORY
# use OS file locking
setopt HIST_FCNTL_LOCK
# don't store immediate dups
setopt HIST_IGNORE_DUPS
# don't store fc/history commands
setopt HIST_NO_STORE
# canonicalize whitespace
setopt HIST_REDUCE_BLANKS
# pause to edit ! item
setopt HIST_VERIFY
# share history between sessions
setopt SHARE_HISTORY
# allow comments on the commandline
setopt INTERACTIVE_COMMENTS
# print exit values for errors
# setopt PRINT_EXIT_VALUE
# I know what I'm doing
setopt RM_STAR_SILENT
# allow short forms of loop commands
setopt SHORT_LOOPS
# don't run BG jobs at lower priority
setopt NOBG_NICE
# long job list
setopt LONG_LIST_JOBS
# notify job events right away
setopt NOTIFY
# allow interpolation in prompts
setopt PROMPT_SUBST
# expand all this=that expressions
setopt MAGIC_EQUAL_SUBST
# unalias run-help
autoload run-help
HELPDIR=/usr/local/share/zsh/helpfiles
fpath=(/usr/local/share/zsh-completions $fpath)
autoload -U compinit
compinit
zstyle ':completion:*' menu select
autoload -U bashcompinit
bashcompinit
autoload -U zmv
bindkey -e
bindkey ' ' magic-space
autoload colors
colors
# colors
for COLOR in RED GREEN YELLOW WHITE BLACK CYAN MAGENTA BLUE; do
eval PR_$COLOR='%{$fg_no_bold[${(L)COLOR}]%}'
eval PR_BRIGHT_$COLOR='%{$fg_bold[${(L)COLOR}]%}'
eval PR_BG_$COLOR='%{$bg_no_bold[${(L)COLOR}]%}'
done
PR_RESET="%{${reset_color}%}";
# VCS setup for prompt
autoload -Uz vcs_info
precmd() { vcs_info 'prompt' }
local ret_status="%(?:%{${PR_BRIGHT_BLACK}%}"$'%?'":%{${PR_BRIGHT_RED}%}"$'%?'"%s)${PR_RESET}"
PROMPT='${ret_status} ${PR_BLUE}%c${vcs_info_msg_0_}${PR_RESET} '
# set formats
# %b - branchname
# %u - unstagedstr (see below)
# %c - stangedstr (see below)
# %a - action (e.g. rebase-i)
# %R - repository path
# %S - path in the repository
FMT_BRANCH="${PR_MAGENTA}%b${PR_RESET}%u%c${PR_BRIGHT_BLUE}%m${PR_RESET}" # e.g. master¹²
FMT_ACTION="${PR_BRIGHT_BLUE}(%a)${PR_RESET}" # e.g. (rebase-i)
FMT_PATH="%R${PR_YELLOW}/%S${PR_RESET}" # e.g. ~/repo/subdir
# check-for-changes can be really slow.
# you should disable it, if you work with large repositories
zstyle ':vcs_info:*:prompt:*' enable git # hg svn bzr cvs
zstyle ':vcs_info:*:prompt:*' branchformat '%b'
zstyle ':vcs_info:*:prompt:*' check-for-changes true
zstyle ':vcs_info:*:prompt:*' unstagedstr "${PR_BRIGHT_RED} ✗${PR_RESET}"
zstyle ':vcs_info:*:prompt:*' stagedstr "${PR_BRIGHT_GREEN} ✗${PR_RESET}"
zstyle ':vcs_info:*:prompt:*' actionformats " ${FMT_BRANCH}${FMT_ACTION}" "${FMT_PATH}"
zstyle ':vcs_info:*:prompt:*' formats " ${FMT_BRANCH}" "${FMT_PATH}"
zstyle ':vcs_info:*:prompt:*' nvcsformats "" "%~"
# git: Show +N/-N when your local branch is ahead-of or behind remote HEAD.
# Make sure you have added misc to your 'formats': %m
zstyle ':vcs_info:git*+set-message:*' hooks git-st
function +vi-git-st() {
local ahead behind
local -a gitstatus
# for git prior to 1.7
ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
(( $ahead )) && gitstatus+=( "+${ahead}" )
# for git prior to 1.7
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
(( $behind )) && gitstatus+=( "-${behind}" )
gitstatus=${(j:/:)gitstatus// /}
(( $gitstatus )) && hook_com[misc]+=" ${gitstatus}"
test -n "${hook_com[misc]}" && hook_com[misc]=" ${(j:/:)hook_com[misc]// /}"
}
# npm completions
source ${HOME}/.bashrc.d/npm.sh
alias binit="bundle install --path vendor"
alias bi="bundle install"
alias be="bundle exec"
# source chruby
source /usr/local/share/chruby/chruby.sh
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
### Haskell
export PATH="${HOME}/.cabal/bin:${PATH}"
### Clojure/Leiningen
export PATH="${HOME}/Scratch/clojure/leiningen:${PATH}"
export LEIN_GPG=gpg2
### Clojure/Boot
export BOOT_CLOJURE_VERSION="1.8.0"
export BOOT_COLOR=false
export BOOT_EMIT_TARGET=no
# I'm pretty sure @notnoopci gave me this super useful function
# for debugging builds, or the build environment, with your code
# available
function runbuild() {
curl -XPOST \
-d revision=$REVISION \
-d parallel=1 \
-d skip-tests=true \
-u ${CIRCLE_TOKEN}: \
https://circleci.com/api/v1/project/circleci/circle/tree/$BRANCH_NAME
}
### Rust
export RUST_SRC_PATH=${HOME}/.rust/src
export PATH=${HOME}/.cargo/bin:${PATH}
### NVM
source $(brew --prefix nvm)/nvm.sh
export NVM_DIR=~/.nvm
nvm use default
### GnuPG
export GPG_TTY=$(tty)
# Make sure the gpg-agent is running
if ! pgrep gpg-agent > /dev/null 2>&1; then
eval $(gpg-agent --daemon --write-env-file ~/.gpg-agent-info)
fi
source ~/.gpg-agent-info
export GPG_AGENT_INFO
# iTerm2 installs this file
source /Users/joni/.iterm2_shell_integration.zsh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment