Skip to content

Instantly share code, notes, and snippets.

@jaigouk
Last active March 4, 2019 13:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaigouk/75fbbeb37f15e860d248ab7a47c32330 to your computer and use it in GitHub Desktop.
Save jaigouk/75fbbeb37f15e860d248ab7a47c32330 to your computer and use it in GitHub Desktop.
switch profiles
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
#WORK
# work-github-id
Host work-github-id.github.com
HostName github.com
User git
IdentityFile ~/.ssh/work-github-rsa
#PERSONAL
# for casual OSS
Host my-github-id.github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
#HACKING
# for something serious
# note. replace github-id-serious with your github id
Host github-id-serious.github.com
HostName github.com
User git
IdentityFile ~/.ssh/serious-rsa
[user]
email = hack@gmail.com
name = Wannabe Hacker
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = git@github-id-serious.github.com:github-id-serious/dotfiles.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
#!/bin/bash
rm -rf $HOME/.gitconfig
touch $HOME/.gitconfig
case "$1" in
hack)
cat > $HOME/.gitconfig << DAT
[user]
email = hack@gmail.com
name = Wannabe Hacker
DAT
ssh-add -D
ssh-add ~/.ssh/serious-rsa
;;
work)
cat > $HOME/.gitconfig <<- DAT
[user]
email = hate@monday.com
name = Boring Work
DAT
ssh-add -D
ssh-add ~/.ssh/work-github-rsa
;;
*)
cat > $HOME/.gitconfig <<- DAT
[user]
email = personal@gmail
name = OSS Work
DAT
ssh-add -D
ssh-add ~/.ssh/id_rsa
;;
esac
cat $HOME/.gitconfig
prompt_git_user() {
(( $+commands[git] )) || return
if [[ "$(git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]]; then
return
fi
local email=`cat $HOME/.gitconfig | sed -n '2p' | sed -e 's/^[[:space:]]*//'`
local newString="${email#*=}"
local sanitized_email=`echo $newString | sed -e 's/^[[:space:]]*//'`
local username=`case $sanitized_email in
(hack@gmail.com) echo hack;;
(personal@gmail) echo personal;;
(hate@monday.com) echo work;;
(*) echo oops;;
esac`
local PL_BRANCH_CHAR
() {
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
PL_BRANCH_CHAR=$'\ue0a0' # 
}
local ref dirty mode repo_path
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
repo_path=$(git rev-parse --git-dir 2>/dev/null)
dirty=$(parse_git_dirty)
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)"
if [[ -n $dirty ]]; then
prompt_segment yellow black
else
prompt_segment green $CURRENT_FG
fi
if [[ -e "${repo_path}/BISECT_LOG" ]]; then
mode=" <B>"
elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then
mode=" >M<"
elif [[ -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then
mode=" >R>"
fi
setopt promptsubst
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' get-revision true
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' stagedstr '✚'
zstyle ':vcs_info:*' unstagedstr '●'
zstyle ':vcs_info:*' formats ' %u%c'
zstyle ':vcs_info:*' actionformats ' %u%c'
vcs_info
echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%%}${mode}[${username}]"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment