Skip to content

Instantly share code, notes, and snippets.

@milljm
Last active June 23, 2020 15:19
Show Gist options
  • Save milljm/cc326af08827d1e1f3cd8b209fa816f3 to your computer and use it in GitHub Desktop.
Save milljm/cc326af08827d1e1f3cd8b209fa816f3 to your computer and use it in GitHub Desktop.
.zshrc profile multi-line, conda/git detection support. Detects when to display user@host (when SSH'd in)
#################################
export CLICOLOR=1
export LSCOLORS=exfxcxdxbxegedabagacad
alias ll='ls -latrh'
alias l='ls -latrh'
export CONDA_HOSTNAME=`hostname`
setopt noautomenu
setopt nomenucomplete
setopt auto_cd
setopt PROMPT_SUBST
autoload -U colors && colors
# 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 " [%{$fg[yellow]%}"${ref#refs/heads/}"%{$reset_color%}]"
}
function conda_env() {
if [ -n "$CONDA_DEFAULT_ENV" ]; then
echo " ($CONDA_DEFAULT_ENV)"
fi
}
function me_at() {
if [ -n "$SSH_CONNECTION" ]; then
echo " [%{$fg_bold[green]%}%n@${CONDA_HOSTNAME}%{$reset_color%}]"
fi
}
export PROMPT='{$(conda_env)$(me_at)$(git_current_branch) } [%{$fg[blue]%}%~%{$reset_color%}]
%{$fg_bold[yellow]%}$%{$reset_color%} '
#################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment