Last active
November 25, 2017 18:00
-
-
Save danreeves/6728721 to your computer and use it in GitHub Desktop.
My zshrc file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### history file config | |
HISTFILE=~/.zsh_history | |
HISTSIZE=999999999 | |
SAVEHIST=$HISTSIZE | |
setopt APPEND_HISTORY | |
### better tab completion | |
autoload -U compinit | |
compinit | |
# case insensitive | |
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' | |
### zsh syntax highlighting | |
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh | |
### up or down history based on what's typed in already | |
autoload -U up-line-or-beginning-search | |
autoload -U down-line-or-beginning-search | |
zle -N up-line-or-beginning-search | |
zle -N down-line-or-beginning-search | |
bindkey "^[[A" up-line-or-beginning-search # Up | |
bindkey "^[[B" down-line-or-beginning-search # Down | |
### Reset the cursor after nvim changes it | |
### autocmd VimLeave * !reset-cursor | |
reset-cursor() { | |
# This is iTerm specific | |
printf '\033]50;CursorShape=1\x7' | |
} | |
### some aliases | |
alias cl='clear' | |
alias vi='nvim; reset-cursor && cl' | |
alias vim='nvim; reset-cursor && cl' | |
alias ls='ls -GFh' | |
### jump to recently used items | |
eval "$(fasd --init zsh-hook zsh-ccomp zsh-ccomp-install zsh-wcomp zsh-wcomp-install)" | |
function fasd_cd() { | |
if [ $# -le 1 ]; then | |
fasd "$@" | |
else | |
local _fasd_ret="$(fasd -e 'printf %s' "$@")" | |
[ -z "$_fasd_ret" ] && return | |
[ -d "$_fasd_ret" ] && cd "$_fasd_ret" || printf %s\\n "$_fasd_ret" | |
fi | |
} | |
alias z='fasd_cd -d' # cd, same functionality as j in autojump | |
### Sublime | |
export PATH=/Applications/Sublime\ Text.app/Contents/SharedSupport/bin:$PATH | |
export EDITOR="nvim" | |
# s [path] | |
# Opens the passed path or the current dir in sublime | |
function s () { | |
# if there's no argument | |
if [ $# -eq 0 ]; then | |
# if this dir has a sublime-project file | |
# if [[ $(find . -maxdepth 1 -name '*.sublime-project' -print -quit) ]]; then | |
# subl ./*.sublime-project | |
# return | |
# fi | |
subl ./ | |
return | |
fi | |
subl $@ | |
} | |
# sz [name] | |
# Uses fasd to search for a likely folder and opens it with sublime | |
function sz () { | |
s $(fasd -e 'printf %s' "$@"); | |
} | |
# Again for Atom | |
function a () { | |
if [ $# -eq 0 ] | |
then | |
atom ./ | |
return | |
fi | |
atom $@ | |
} | |
### Copy my ssh key to clipboard | |
function myssh () { | |
if pbcopy < ~/.ssh/id_rsa.pub ; then | |
echo '๐ โ ๐ ssh key copied to clipboard!' | |
else | |
echo '๐ฉ something went wrong!' | |
fi | |
} | |
### git | |
alias gaa='git add -A' | |
alias gs='git status' | |
alias gcm='git commit -m' | |
alias gca='git commit --amend --no-edit' | |
alias gce='git commit --amend' | |
alias gco='git checkout' | |
alias gd='git diff --ignore-space-at-eol --ignore-space-change --ignore-all-space --ignore-blank-lines' | |
alias glg='git glog' | |
alias gpp='git pull --rebase && git push' | |
### Cache pip-installed packages to avoid re-downloading | |
export PIP_DOWNLOAD_CACHE=$HOME/.pip/cache | |
### docker | |
alias dock="docker-compose" | |
alias d="docker-compose" | |
## Probably not needed on docker 0.13+ | |
function spacedock () { | |
echo 'Deleting exited and unused docker vms and images'; | |
read "imsure?Are you sure? " | |
if [[ "$imsure" =~ ^[Yy]$ ]] | |
then # do dangerous stuff | |
echo '๐ Making space'; | |
docker ps -a | grep 'Exit' | awk '{print $1}' | xargs docker rm; | |
docker images | grep '<none>' | awk '{print $3}' | xargs docker rmi; | |
fi | |
} | |
# Open a package on the npm website | |
function npm-open () { | |
open https://npmjs.com/package/$1 | |
} | |
### wp-cli fixes (with MAMP) | |
# default to PHP 7 | |
export WP_CLI_PHP=`find /Applications/MAMP/bin/php -type f -name php | sort -n | tail -1` | |
function wp_cli_php () { | |
export WP_CLI_PHP=`find /Applications/MAMP/bin/php -type f -name php | sort -n | grep $@ | tail -1` | |
} | |
### wp-cli/MAMP mysql fix | |
export PATH="$PATH:/Applications/MAMP/Library/bin" | |
### Homebrew path๐บ | |
export PATH="/usr/local/sbin:$PATH" | |
### nvm | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm | |
# [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion | |
# lotad | |
alias lotad='img-cat ~/Pictures/270.png' | |
alias myip="ifconfig en0 | grep inet | awk '{print $2}' | cut -d':' -f2" | |
### pure prompt | |
autoload -U promptinit && promptinit | |
prompt pure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment