Last active
March 4, 2019 13:46
-
-
Save jaigouk/75fbbeb37f15e860d248ab7a47c32330 to your computer and use it in GitHub Desktop.
switch profiles
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
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 |
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
[user] | |
email = [email protected] | |
name = Wannabe Hacker | |
[core] | |
repositoryformatversion = 0 | |
filemode = true | |
bare = false | |
logallrefupdates = true | |
ignorecase = true | |
precomposeunicode = true | |
[remote "origin"] | |
url = [email protected]:github-id-serious/dotfiles.git | |
fetch = +refs/heads/*:refs/remotes/origin/* | |
[branch "master"] | |
remote = origin | |
merge = refs/heads/master |
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
#!/bin/bash | |
rm -rf $HOME/.gitconfig | |
touch $HOME/.gitconfig | |
case "$1" in | |
hack) | |
cat > $HOME/.gitconfig << DAT | |
[user] | |
email = [email protected] | |
name = Wannabe Hacker | |
DAT | |
ssh-add -D | |
ssh-add ~/.ssh/serious-rsa | |
;; | |
work) | |
cat > $HOME/.gitconfig <<- DAT | |
[user] | |
email = [email protected] | |
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 |
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
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 | |
([email protected]) echo hack;; | |
(personal@gmail) echo personal;; | |
([email protected]) 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