Skip to content

Instantly share code, notes, and snippets.

@wass3r
Last active July 17, 2018 15:25
Show Gist options
  • Select an option

  • Save wass3r/e1391407c01581ff0d8e8ce9c1ecd726 to your computer and use it in GitHub Desktop.

Select an option

Save wass3r/e1391407c01581ff0d8e8ce9c1ecd726 to your computer and use it in GitHub Desktop.
export GOPATH=~/go
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GRADLE_HOME/bin
export PATH=$PATH:$JAVA_HOME/bin
export GREP_COLOR='1;31'
export EDITOR='nvim'
export BROWSER='open -a firefox'
alias la='exa -la --git --group-directories-first --sort=mod'
alias dls='ls -d1 .*/ */'
alias ..='cd ..' # Go up one directory
alias ...='cd ../..' # Go up two directories
alias ....='cd ../../..' # And for good measure
alias firefox='open -a firefox'
alias ff='firefox'
alias brewup='brew update; brew upgrade; brew prune; brew cleanup; brew doctor'
alias k='kubectl'
alias kcc='k config current-context'
alias kuc='k config use-context'
alias kgp='k get pods'
alias kl='k logs'
alias grep='grep --color=auto' # Always highlight grep search term
alias ping='ping -c 5' # Pings with 5 packets, not unlimited
alias df='df -h' # Disk free, in gigabytes, not bytes
alias du='du -h -c' # Calculate total disk usage for a folder
alias sgi='sudo gem install' # Install ruby stuff
alias be='bundle exec' # shortcut for ruby environment activation
alias dc='docker-compose' # invoke docker-compose, which takes too long to type.
# open current repo in browser
# alias gho='$(git remote -v 2> /dev/null | grep github | sed -e "s/.*git\:\/\/\([a-z]\.\)*/\1/" -e "s/\.git.*//g" -e "s/.*@\(.*\)$/\1/g" | tr ":" "/" | tr -d "\011" | sed -e "s/^/open http:\/\//g" | uniq)'
alias gho='hub browse'
eval "$(jump shell)"
autoload -U compinit colors vcs_info
colors
compinit
# Report command running time if it is more than 3 seconds
export REPORTTIME=3
export HISTCONTROL=erasedups
export HISTIGNORE="&:ls:ll:la:l.:pwd:exit:clear:clr:[bf]g"
export HISTFILE=~/.zhistory
export HISTSIZE=200
export SAVEHIST=200
setopt appendhistory autocd nomatch autopushd pushdignoredups promptsubst histignorealldups histignorespace
unsetopt beep correctall
zstyle ':completion:*' completer _complete _correct _approximate
# zstyle ':vcs_info:*+*:*' debug true
zstyle ':vcs_info:git:*' check-for-changes true
zstyle ':vcs_info:*' get-revision true
zstyle ':vcs_info:*' stagedstr '+'
zstyle ':vcs_info:*' unstagedstr '*'
zstyle ':vcs_info:git*' formats "%F{75}| %F{gray}%b%f%u%c"
zstyle ':vcs_info:git*+set-message:*' hooks git-untracked git-st
function +vi-git-untracked() {
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \
git status --porcelain | grep '??' &> /dev/null ; then
hook_com[staged]+='!'
fi
}
function +vi-git-st() {
local ahead behind
local -a gitstatus
ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
(( $ahead )) && gitstatus+=( "%F{75}/%f+${ahead//[[:space:]]/}" )
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
(( $behind )) && gitstatus+=( "-${behind//[[:space:]]/}" )
if [[ -n "${(j:/:)gitstatus// }" ]]; then
hook_com[branch]="${hook_com[branch]}${(j:/:)gitstatus}%F{75}/%f"
else
hook_com[branch]+="%F{75}/%f"
fi
}
_setup_ps1 () {
vcs_info
GLYPH="/"
[ "x$KEYMAP" = "xvicmd" ] && GLYPH=":"
PS1="
%F{gray} / %F{blue}%(5~|%-2~/.../%3~|%~) $vcs_info_msg_0_
%F{gray}%(?.%F{gray}.%F{red})$GLYPH%f/ %F{244}%# %f"
# PS1=" %(?.%F{blue}.%F{red})$GLYPH%f %(1j.%F{cyan}[%j]%f .)%F{blue}%~%f %(!.%F{red}#%f .)"
# RPROMPT="$vcs_info_msg_0_"
}
_setup_ps1
# determines what type of archive you have (based on file extension) and executes
# the correct incantation to unarchive it.
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7zr e $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# make a dir and cd into it
mcd () {
mkdir -p "$@" && cd "$@"
}
# helper to download git repo in right folder; depends on hub (brew install hub)
ghget () {
# input: rails/rails
USER=$(echo $@ | tr "/" " " | awk '{print $1}')
REPO=$(echo $@ | tr "/" " " | awk '{print $2}')
mcd "$HOME/git-repos/$USER" && \
hub clone $@ && \
cd $REPO
}
# kill process using port
portslay () {
kill -9 `lsof -i tcp:$1 | tail -1 | awk '{ print $2;}'`
}
exip () {
# gather external ip address
echo -n "Current External IP: "
curl -s -m 5 http://myip.dk | grep "ha4" | sed -e 's/.*ha4">//g' -e 's/<\/span>.*//g'
}
ips () {
# determine local IP address
ifconfig | grep "inet " | awk '{ print $2 }'
}
# Vi mode
zle-keymap-select () {
_setup_ps1
zle reset-prompt
}
zle -N zle-keymap-select
zle-line-init () {
zle -K viins
}
zle -N zle-line-init
bindkey -v
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# source $HOME/.asdf/asdf.sh
# source $HOME/.asdf/completions/asdf.bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment