Last active
June 23, 2020 15:15
-
-
Save milljm/69f653be030a0c57632a7f4e1bc8f564 to your computer and use it in GitHub Desktop.
Bash profile multi-line, conda/git detection support. Detects when to display user@host (when SSH'd in)
This file contains 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
################################# | |
export CLICOLOR=1 | |
export LSCOLORS=exfxcxdxbxegedabagacad | |
alias ll='ls -latrh' | |
alias l='ls -latrh' | |
# git branch function (stole this from ohmyzsh) | |
function git_current_branch() { | |
local ref | |
ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null) | |
local ret=$? | |
if [[ $ret != 0 ]]; then | |
[[ $ret == 128 ]] && return # no git repo. | |
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return | |
fi | |
echo -e " [\033[1;33m"${ref#refs/heads/}"\033[0m]" | |
} | |
function conda_env() { | |
if [ -n "$CONDA_DEFAULT_ENV" ]; then | |
echo " ($CONDA_DEFAULT_ENV)" | |
fi | |
} | |
function me_at() { | |
if [ -n "$SSH_CONNECTION" ]; then | |
echo " [\033[0;92m\\u@\\h\033[0m]" | |
fi | |
} | |
PS1="{\$(conda_env)$(me_at)\$(git_current_branch) } [\033[0;34m\w\033[0m] | |
$ " | |
################################# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment