Skip to content

Instantly share code, notes, and snippets.

@webbower
Last active February 21, 2025 19:13
Show Gist options
  • Save webbower/4ee7c542d830e0acae11 to your computer and use it in GitHub Desktop.
Save webbower/4ee7c542d830e0acae11 to your computer and use it in GitHub Desktop.
Global Git and ZSh config
[alias]
co = checkout
ci = commit
st = status
br = branch
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
type = cat-file -t
dump = cat-file -p
current-branch = rev-parse --abbrev-ref HEAD
cb = rev-parse --abbrev-ref HEAD
unstage = reset HEAD --
us = reset HEAD --
revert = checkout --
rv = checkout --
wip = commit -am \"wip\"
rollback = reset HEAD~1
rb = reset HEAD~1
[core]
editor = vi
[branch]
autosetupmerge = always
; autosetuprebase = always
[push]
; autoSetupRemote = true
; Omit branch/refspec from `git push`
default = current
[init]
defaultBranch = main
[remote]
; Omit remote from `git push`
pushDefault = origin
stty erase "^?"
export LC_CTYPE=en_US.UTF-8;
export DISPLAY=:0.0;
export EDITOR="vi";
export HISTCONTROL=erasedups;
export HISTFILESIZE=10000000;
export HISTSIZE=100000;
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
txtcyn='\e[0;36m' # Cyan
txtwht='\e[0;37m' # White
bldblk='\e[1;30m' # Black - Bold
bldred='\e[1;31m' # Red
bldgrn='\e[1;32m' # Green
bldylw='\e[1;33m' # Yellow
bldblu='\e[1;34m' # Blue
bldpur='\e[1;35m' # Purple
bldcyn='\e[1;36m' # Cyan
bldwht='\e[1;37m' # White
unkblk='\e[4;30m' # Black - Underline
undred='\e[4;31m' # Red
undgrn='\e[4;32m' # Green
undylw='\e[4;33m' # Yellow
undblu='\e[4;34m' # Blue
undpur='\e[4;35m' # Purple
undcyn='\e[4;36m' # Cyan
undwht='\e[4;37m' # White
bakblk='\e[40m' # Black - Background
bakred='\e[41m' # Red
badgrn='\e[42m' # Green
bakylw='\e[43m' # Yellow
bakblu='\e[44m' # Blue
bakpur='\e[45m' # Purple
bakcyn='\e[46m' # Cyan
bakwht='\e[47m' # White
txtrst='\e[0m' # Text Reset
# https://medium.com/pareture/simplest-zsh-prompt-configs-for-git-branch-name-3d01602a6f33
setopt prompt_subst
# https://davidwalsh.name/show-git-branch-command-line
function parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
# Customize ZSH prompt
# https://scriptingosx.com/2019/07/moving-to-zsh-06-customizing-the-zsh-prompt/
# https://superuser.com/questions/382503/how-can-i-put-a-newline-in-my-zsh-prompt-without-causing-terminal-redraw-issues
NEWLINE=$'\n'
PROMPT='%F{red}%~:%F{white} %F{magenta}$(parse_git_branch)%F{white}${NEWLINE}%% '
# alias m="mate";
alias ls="ls -GhF";
alias ll="ls -l";
alias lla="ls -lA";
alias cp="cp -i";
alias rm="rm -i";
alias clr="clear";
alias chop="tr -d '\r\n'"
alias reload=". ~/.zsh_reset;";
alias push="git push origin --all";
alias pull="git pull origin";
alias kdock="killall Dock";
alias newpass="mkpwd -n 10 -m 10 -t 2 | pbcopy";
alias getip="curl -s http://whatismyip.org/ | pbcopy; pbpaste; echo;";
alias beep="osascript -e \"beep\"";
alias listhist="history|awk '{print $2}'|awk 'BEGIN {FS=\"|\"} {print $1}'|sort|uniq -c|sort -r";
alias erc="vi ~/.zshrc";
alias epro="vi ~/.zsh_profile";
alias erst="vi ~/.zsh_reset";
alias flush="sudo killall -HUP mDNSResponder";
alias pbclear="printf \"\" | pbcopy";
alias gws="git diff --check";
alias gmp="git checkout main && git pull";
# Make a new directory and then go into it. Supports deep folder creation.
function mc() {
mkdir -p "$1";
cd "$1";
}
# Make a new directory and then open it in Finder. Supports deep folder creation.
function mo() {
mkdir -p "$1";
open "$1";
}
# Make a new directory and init Git inside of it
function mcg() {
mc "$1";
git init;
touch .gitignore README.md;
git add .gitignore README.md;
git commit -m "Initial project structure";
}
function datedir() {
if [[ $# -eq 1 ]]; then
mkdir $1/`date +%Y-%m-%d`;
else
mkdir ./`date +%Y-%m-%d`;
fi
}
function line() {
sed "${1}q;d" "$2"
}
function clear_tmp() {
printf "" > $TMP_FILE;
}
function exists() {
test -e "$1" && echo 'exists' || echo 'nope';
}
export PATH="./node_modules/.bin:$PATH";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment