Skip to content

Instantly share code, notes, and snippets.

@kahunacohen
Last active March 21, 2023 12:18
Show Gist options
  • Save kahunacohen/edae2ead20e6c914c94bbb5a28376e07 to your computer and use it in GitHub Desktop.
Save kahunacohen/edae2ead20e6c914c94bbb5a28376e07 to your computer and use it in GitHub Desktop.
# General
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export PATH=$PATH:$HOME/bin
# Load version control information
autoload -Uz vcs_info
precmd() { vcs_info }
# Format the vcs_info_msg_0_ variable
zstyle ':vcs_info:git:*' formats '(%b)'
# Set up the prompt (with git branch name)
setopt PROMPT_SUBST
PROMPT='%n ${PWD/#$HOME/~} ${vcs_info_msg_0_}$ '
# git
alias gd="git diff"
alias gs='git status'
alias gp='git push'
alias kb='kubectl'
alias latest_tag='git tag | sort -V | tail -n1'
alias diff_latest_tag='git diff `latest_tag`'
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
# git branch search
function gbs {
ret=$(git branch | grep $1)
if [ "$?" -ne 0 ]; then
>&2 echo "Search for $1 got > 1 branches:"
>&2 echo "$ret"
return 1
else
git branch $ret
fi
}
# GO
export PATH="$HOME/projects/mobileapp-client/node_modules/.bin:$PATH"
export GOPATH=$HOME/go
function go_init_proj {
local my_proj_path=$GOPATH/src/github.com/kahunacohen/$1
mkdir -p $my_proj_path
touch $my_proj_path/.gitignore
touch $my_proj_path/README.md
cat <<EOF > "$my_proj_path/main.go"
package main
import "fmt"
func main() {
fmt.Println("hello $1")
}
EOF
cd $my_proj_path
go mod init
go run .
}
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment