Skip to content

Commit

Permalink
move virtual env function in the path section, move the display from …
Browse files Browse the repository at this point in the history
…the front to the path section of the prompt, inside brackets, add flepied as an author, update the readme
  • Loading branch information
nojhan committed Jan 3, 2013
1 parent cb598c1 commit 45cdcdb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -53,6 +53,7 @@ different colors for each case;
a red one if he has not;
* the current directory in bold, shortened if it takes too much space, while
preserving the first two directories;
* the current Python virtual environment, if any;
* an up arrow if an HTTP proxy is in use;
* the name of the current branch if you are in a version control repository
(git, mercurial or subversion), in green if everything is up to date, in red if
Expand Down
23 changes: 12 additions & 11 deletions liquidprompt
Expand Up @@ -34,7 +34,7 @@
# Florian Le Frioux <florian@lefrioux.fr> # Use ± mark when root in VCS dir.
# Luc Didry <luc@fiat-tux.fr> # Zsh port
# Olivier Mengué <dolmen@cpan.org> # Major optimizations on host parsing

# Frédéric Lepied # Python virtual env

# See the README.md file for a summary of features.

Expand Down Expand Up @@ -507,6 +507,13 @@ _lp_permissions_color()
fi
}

# Display the current Python virtual environnement, if available.
_lp_virtualenv()
{
[[ "$LP_ENABLE_VIRTUALENV" != 1 ]] && return
[[ -n "$VIRTUAL_ENV" ]] && echo "[$(basename \"$VIRTUAL_ENV\")]"
}


################
# Related jobs #
Expand Down Expand Up @@ -961,12 +968,6 @@ _lp_time()
echo -ne "${LP_COLOR_TIME}$(date +%H:%M:%S)${NO_COL}"
}

_lp_virtualenv()
{
[[ "$LP_ENABLE_VIRTUALENV" != 1 ]] && return
[[ -n "$VIRTUAL_ENV" ]] && echo "(`basename \"$VIRTUAL_ENV\"`)"
}

########################
# Construct the prompt #
########################
Expand All @@ -980,7 +981,6 @@ _lp_set_prompt()
$LP_OLD_PROMPT_COMMAND

# left of main prompt: space at right
LP_VENV=$(_lp_sr "$(_lp_virtualenv)")
LP_JOBS=$(_lp_sr "$(_lp_jobcount_color)")
LP_LOAD=$(_lp_sr "$(_lp_load_color)")
LP_BATT=$(_lp_sr "$(_lp_battery_color)")
Expand All @@ -998,6 +998,7 @@ _lp_set_prompt()
LP_PROXY="${LP_COLOR_PROXY}$(_lp_proxy)${NO_COL}"

# right of main prompt: space at left
LP_VENV=$(_lp_sl "$(_lp_virtualenv)")
LP_GIT=$(_lp_sl "$(_lp_git_branch_color)")
LP_HG=$(_lp_sl "$(_lp_hg_branch_color)")
LP_SVN=$(_lp_sl "$(_lp_svn_branch_color)")
Expand All @@ -1014,20 +1015,20 @@ _lp_set_prompt()

if [[ -z $LP_PS1 ]] ; then
# add time, jobs, load and battery
PS1="${LP_VENV}${LP_TIME}${LP_BATT}${LP_LOAD}${LP_JOBS}"
PS1="${LP_TIME}${LP_BATT}${LP_LOAD}${LP_JOBS}"
# add user, host and permissions colon
PS1="${PS1}[${LP_USER}${LP_HOST}${LP_PERM}"

# if not root
if [[ "$EUID" -ne "0" ]]
then
# path in foreground color
PS1="${PS1}${LP_PWD}]${LP_PROXY}"
PS1="${PS1}${LP_PWD}]${LP_VENV}${LP_PROXY}"
# add VCS infos
PS1="${PS1}${LP_GIT}${LP_HG}${LP_SVN}"
else
# path in yellow
PS1="${PS1}${LP_PWD}]${LP_PROXY}"
PS1="${PS1}${LP_PWD}]${LP_VENV}${LP_PROXY}"
# do not add VCS infos
fi
# add return code and prompt mark
Expand Down

0 comments on commit 45cdcdb

Please sign in to comment.