Merge remote-tracking branch 'origin/master' into GH-1142
This commit is contained in:
@@ -7,6 +7,8 @@ CLOCK_THEME_PROMPT_SUFFIX=''
|
||||
|
||||
THEME_PROMPT_HOST='\H'
|
||||
|
||||
SCM=
|
||||
|
||||
SCM_CHECK=${SCM_CHECK:=true}
|
||||
|
||||
SCM_THEME_PROMPT_DIRTY=' ✗'
|
||||
@@ -30,6 +32,7 @@ SCM_GIT_SHOW_REMOTE_INFO=${SCM_GIT_SHOW_REMOTE_INFO:=auto}
|
||||
SCM_GIT_IGNORE_UNTRACKED=${SCM_GIT_IGNORE_UNTRACKED:=false}
|
||||
SCM_GIT_SHOW_CURRENT_USER=${SCM_GIT_SHOW_CURRENT_USER:=false}
|
||||
SCM_GIT_SHOW_MINIMAL_INFO=${SCM_GIT_SHOW_MINIMAL_INFO:=false}
|
||||
SCM_GIT_SHOW_STASH_INFO=${SCM_GIT_SHOW_STASH_INFO:=true}
|
||||
|
||||
SCM_GIT='git'
|
||||
SCM_GIT_CHAR='±'
|
||||
@@ -42,6 +45,12 @@ SCM_GIT_STAGED_CHAR="S:"
|
||||
SCM_GIT_STASH_CHAR_PREFIX="{"
|
||||
SCM_GIT_STASH_CHAR_SUFFIX="}"
|
||||
|
||||
SCM_P4='p4'
|
||||
SCM_P4_CHAR='⌛'
|
||||
SCM_P4_CHANGES_CHAR='C:'
|
||||
SCM_P4_DEFAULT_CHAR='D:'
|
||||
SCM_P4_OPENED_CHAR='O:'
|
||||
|
||||
SCM_HG='hg'
|
||||
SCM_HG_CHAR='☿'
|
||||
|
||||
@@ -58,6 +67,8 @@ THEME_SHOW_USER_HOST=${THEME_SHOW_USER_HOST:=false}
|
||||
USER_HOST_THEME_PROMPT_PREFIX=''
|
||||
USER_HOST_THEME_PROMPT_SUFFIX=''
|
||||
|
||||
VIRTUAL_ENV=
|
||||
|
||||
VIRTUALENV_THEME_PROMPT_PREFIX=' |'
|
||||
VIRTUALENV_THEME_PROMPT_SUFFIX='|'
|
||||
|
||||
@@ -69,11 +80,12 @@ RBFU_THEME_PROMPT_SUFFIX='|'
|
||||
|
||||
function scm {
|
||||
if [[ "$SCM_CHECK" = false ]]; then SCM=$SCM_NONE
|
||||
elif [[ -f .git/HEAD ]]; then SCM=$SCM_GIT
|
||||
elif [[ -f .git/HEAD ]] && which git &> /dev/null; then SCM=$SCM_GIT
|
||||
elif which git &> /dev/null && [[ -n "$(git rev-parse --is-inside-work-tree 2> /dev/null)" ]]; then SCM=$SCM_GIT
|
||||
elif [[ -d .hg ]]; then SCM=$SCM_HG
|
||||
elif which p4 &> /dev/null && [[ -n "$(p4 set P4CLIENT 2> /dev/null)" ]]; then SCM=$SCM_P4
|
||||
elif [[ -d .hg ]] && which hg &> /dev/null; then SCM=$SCM_HG
|
||||
elif which hg &> /dev/null && [[ -n "$(hg root 2> /dev/null)" ]]; then SCM=$SCM_HG
|
||||
elif [[ -d .svn ]]; then SCM=$SCM_SVN
|
||||
elif [[ -d .svn ]] && which svn &> /dev/null; then SCM=$SCM_SVN
|
||||
else SCM=$SCM_NONE
|
||||
fi
|
||||
}
|
||||
@@ -81,6 +93,7 @@ function scm {
|
||||
function scm_prompt_char {
|
||||
if [[ -z $SCM ]]; then scm; fi
|
||||
if [[ $SCM == $SCM_GIT ]]; then SCM_CHAR=$SCM_GIT_CHAR
|
||||
elif [[ $SCM == $SCM_P4 ]]; then SCM_CHAR=$SCM_P4_CHAR
|
||||
elif [[ $SCM == $SCM_HG ]]; then SCM_CHAR=$SCM_HG_CHAR
|
||||
elif [[ $SCM == $SCM_SVN ]]; then SCM_CHAR=$SCM_SVN_CHAR
|
||||
else SCM_CHAR=$SCM_NONE_CHAR
|
||||
@@ -93,6 +106,7 @@ function scm_prompt_vars {
|
||||
SCM_DIRTY=0
|
||||
SCM_STATE=''
|
||||
[[ $SCM == $SCM_GIT ]] && git_prompt_vars && return
|
||||
[[ $SCM == $SCM_P4 ]] && p4_prompt_vars && return
|
||||
[[ $SCM == $SCM_HG ]] && hg_prompt_vars && return
|
||||
[[ $SCM == $SCM_SVN ]] && svn_prompt_vars && return
|
||||
}
|
||||
@@ -125,8 +139,9 @@ function scm_prompt_info_common {
|
||||
fi
|
||||
|
||||
# TODO: consider adding minimal status information for hg and svn
|
||||
{ [[ ${SCM:-} == ${SCM_HG} ]] && hg_prompt_info && return; } || true
|
||||
{ [[ ${SCM:-} == ${SCM_SVN} ]] && svn_prompt_info && return; } || true
|
||||
{ [[ ${SCM} == ${SCM_P4} ]] && p4_prompt_info && return; } || true
|
||||
{ [[ ${SCM} == ${SCM_HG} ]] && hg_prompt_info && return; } || true
|
||||
{ [[ ${SCM} == ${SCM_SVN} ]] && svn_prompt_info && return; } || true
|
||||
}
|
||||
|
||||
function git_prompt_minimal_info {
|
||||
@@ -167,9 +182,11 @@ function git_prompt_vars {
|
||||
[[ "${commits_ahead}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_AHEAD_CHAR}${commits_ahead}"
|
||||
[[ "${commits_behind}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_BEHIND_CHAR}${commits_behind}"
|
||||
|
||||
local stash_count
|
||||
stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')"
|
||||
[[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_STASH_CHAR_PREFIX}${stash_count}${SCM_GIT_STASH_CHAR_SUFFIX}"
|
||||
if [[ "${SCM_GIT_SHOW_STASH_INFO}" = "true" ]]; then
|
||||
local stash_count
|
||||
stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')"
|
||||
[[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_STASH_CHAR_PREFIX}${stash_count}${SCM_GIT_STASH_CHAR_SUFFIX}"
|
||||
fi
|
||||
|
||||
SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
|
||||
if ! _git-hide-status; then
|
||||
@@ -193,6 +210,26 @@ function git_prompt_vars {
|
||||
SCM_CHANGE=$(_git-short-sha 2>/dev/null || echo "")
|
||||
}
|
||||
|
||||
function p4_prompt_vars {
|
||||
IFS=$'\t' read -r \
|
||||
opened_count non_default_changes default_count \
|
||||
add_file_count edit_file_count delete_file_count \
|
||||
<<< "$(_p4-opened-counts)"
|
||||
if [[ "${opened_count}" -gt 0 ]]; then
|
||||
SCM_DIRTY=1
|
||||
SCM_STATE=${SCM_THEME_PROMPT_DIRTY}
|
||||
[[ "${opened_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_P4_OPENED_CHAR}${opened_count}"
|
||||
[[ "${non_default_changes}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_P4_CHANGES_CHAR}${non_default_changes}"
|
||||
[[ "${default_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_P4_DEFAULT_CHAR}${default_count}"
|
||||
else
|
||||
SCM_DIRTY=0
|
||||
SCM_STATE=${SCM_THEME_PROMPT_DIRTY}
|
||||
fi
|
||||
|
||||
SCM_PREFIX=${P4_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX}
|
||||
SCM_SUFFIX=${P4_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX}
|
||||
}
|
||||
|
||||
function svn_prompt_vars {
|
||||
if [[ -n $(svn status 2> /dev/null) ]]; then
|
||||
SCM_DIRTY=1
|
||||
@@ -299,6 +336,10 @@ function ruby_version_prompt {
|
||||
echo -e "$(rbfu_version_prompt)$(rbenv_version_prompt)$(rvm_version_prompt)$(chruby_version_prompt)"
|
||||
}
|
||||
|
||||
function k8s_context_prompt {
|
||||
echo -e "$(kubectl config current-context)"
|
||||
}
|
||||
|
||||
function virtualenv_prompt {
|
||||
if [[ -n "$VIRTUAL_ENV" ]]; then
|
||||
virtualenv=`basename "$VIRTUAL_ENV"`
|
||||
@@ -313,7 +354,7 @@ function condaenv_prompt {
|
||||
}
|
||||
|
||||
function py_interp_prompt {
|
||||
py_version=$(python --version 2>&1 | awk '{print "py-"$2;}') || return
|
||||
py_version=$(python --version 2>&1 | awk 'NR==1{print "py-"$2;}') || return
|
||||
echo -e "${PYTHON_THEME_PROMPT_PREFIX}${py_version}${PYTHON_THEME_PROMPT_SUFFIX}"
|
||||
}
|
||||
|
||||
@@ -359,10 +400,16 @@ function user_host_prompt {
|
||||
|
||||
# backwards-compatibility
|
||||
function git_prompt_info {
|
||||
_git-hide-status && return
|
||||
git_prompt_vars
|
||||
echo -e "${SCM_PREFIX}${SCM_BRANCH}${SCM_STATE}${SCM_SUFFIX}"
|
||||
}
|
||||
|
||||
function p4_prompt_info() {
|
||||
p4_prompt_vars
|
||||
echo -e "${SCM_PREFIX}${SCM_BRANCH}:${SCM_CHANGE}${SCM_STATE}${SCM_SUFFIX}"
|
||||
}
|
||||
|
||||
function svn_prompt_info {
|
||||
svn_prompt_vars
|
||||
echo -e "${SCM_PREFIX}${SCM_BRANCH}${SCM_STATE}${SCM_SUFFIX}"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function prompt_command() {
|
||||
PS1="${green}\u@\h $(clock_prompt) ${reset_color}${white}\w${reset_color}$(scm_prompt_info)${blue} →${bold_blue} ${reset_color} ";
|
||||
PS1="${green}\u@\h $(clock_prompt) ${reset_color}${white}\w${reset_color}$(scm_prompt_info)${blue} →${bold_blue} ${reset_color} ${normal}";
|
||||
}
|
||||
|
||||
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$blue"}
|
||||
|
||||
22
themes/codeword/README.md
Normal file
22
themes/codeword/README.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# Single line PS1 theme w/realtime history among windows
|
||||
|
||||
|
||||
Minimal theme overrides from bash_it base theming
|
||||
|
||||
|
||||
## `user@host:path[virt-env][scm] $`
|
||||
Breakdown of the segments:
|
||||
|
||||
- **user@host:path** - *convienient for LAN based `ssh` and `scp` tasks*
|
||||
- [**virtualenv**] - *only appears when activated*
|
||||
- [**scm**] - *only appears when activated*
|
||||
- **marker** - *$ or # depending on current user*
|
||||
|
||||
### Examples
|
||||
|
||||
```bash
|
||||
user@example.lan:~ $ cd /tmp/foo/bar/baz
|
||||
user@example.lan:/tmp/foo/bar/baz $ cd $HOME/workspace
|
||||
user@example.lan:~/workspace $ cd sampleRepo/
|
||||
user@example.lan:~/workspace/sampleRepo [± |master ↑1 ↓3 {1} S:2 ?:1 ✗|] $
|
||||
```
|
||||
38
themes/codeword/codeword.theme.bash
Normal file
38
themes/codeword/codeword.theme.bash
Normal file
@@ -0,0 +1,38 @@
|
||||
SCM_THEME_PROMPT_PREFIX=${SCM_THEME_PROMPT_SUFFIX}
|
||||
SCM_THEME_PROMPT_DIRTY="${bold_red} ✗${normal}"
|
||||
SCM_THEME_PROMPT_CLEAN="${bold_green} ✓${normal}"
|
||||
SCM_GIT_CHAR="${green}±${normal}"
|
||||
|
||||
scm_prompt() {
|
||||
CHAR=$(scm_char)
|
||||
if [ $CHAR = $SCM_NONE_CHAR ]
|
||||
then
|
||||
return
|
||||
else
|
||||
echo " [$(scm_char)$(scm_prompt_info)]"
|
||||
fi
|
||||
}
|
||||
|
||||
mark_prompt() {
|
||||
echo "${green}\$${normal}"
|
||||
}
|
||||
|
||||
user_host_path_prompt() {
|
||||
ps_user="${green}\u${normal}";
|
||||
ps_host="${blue}\H${normal}";
|
||||
ps_path="${yellow}\w${normal}";
|
||||
echo "$ps_user@$ps_host:$ps_path"
|
||||
}
|
||||
|
||||
prompt() {
|
||||
PS1="$(user_host_path_prompt)$(virtualenv_prompt)$(scm_prompt) $(mark_prompt) "
|
||||
}
|
||||
|
||||
share_history() {
|
||||
history -a
|
||||
history -c
|
||||
history -r
|
||||
}
|
||||
|
||||
safe_append_prompt_command share_history
|
||||
safe_append_prompt_command prompt
|
||||
@@ -100,8 +100,7 @@ prompt() {
|
||||
|
||||
if [ $(uname) = "Linux" ];
|
||||
then
|
||||
PS1="${TITLEBAR}
|
||||
${SAVE_CURSOR}${MOVE_CURSOR_RIGHTMOST}${MOVE_CURSOR_5_LEFT}\
|
||||
PS1="${TITLEBAR}${SAVE_CURSOR}${MOVE_CURSOR_RIGHTMOST}${MOVE_CURSOR_5_LEFT}
|
||||
$(safe_battery_charge)${RESTORE_CURSOR}\
|
||||
${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}\
|
||||
at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\
|
||||
@@ -113,7 +112,7 @@ ${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}"
|
||||
else
|
||||
PS1="${TITLEBAR}
|
||||
${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}\
|
||||
at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\
|
||||
at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\
|
||||
in ${D_DIR_COLOR}\w ${D_INTERMEDIATE_COLOR}\
|
||||
${LAST_COMMAND_FAILED}\
|
||||
$(demula_vcprompt)\
|
||||
|
||||
23
themes/elixr/elixr.theme.bash
Normal file
23
themes/elixr/elixr.theme.bash
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
SCM_THEME_PROMPT_DIRTY=" ${red}✗"
|
||||
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
||||
SCM_THEME_PROMPT_PREFIX=" ${green}| "
|
||||
SCM_THEME_PROMPT_SUFFIX="${green} |"
|
||||
SCM_NONE_CHAR='◐ '
|
||||
SCM_GIT_SHOW_MINIMAL_INFO=true
|
||||
GIT_THEME_PROMPT_DIRTY=" ${red}✗"
|
||||
GIT_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
||||
GIT_THEME_PROMPT_PREFIX=" ${green}|"
|
||||
GIT_THEME_PROMPT_SUFFIX="${green}|"
|
||||
|
||||
RVM_THEME_PROMPT_PREFIX="|"
|
||||
RVM_THEME_PROMPT_SUFFIX=" d|"
|
||||
|
||||
BOLD="\[\e[1m\]"
|
||||
|
||||
function prompt_command() {
|
||||
PS1="\n${bold_cyan}$(scm_prompt_char_info)$(virtualenv_prompt) ${bold_cyan}\w :${reset_color}${normal}${BOLD} "
|
||||
}
|
||||
|
||||
safe_append_prompt_command prompt_command
|
||||
@@ -71,7 +71,8 @@ function _git-hide-status {
|
||||
}
|
||||
|
||||
function _git-status {
|
||||
[[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && local git_status_flags='-uno' || true
|
||||
local git_status_flags=
|
||||
[[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && git_status_flags='-uno' || true
|
||||
git status --porcelain ${git_status_flags} 2> /dev/null
|
||||
}
|
||||
|
||||
@@ -103,6 +104,8 @@ function _git-remote-info {
|
||||
[[ "$(_git-upstream)" == "" ]] && return || true
|
||||
|
||||
[[ "$(_git-branch)" == "$(_git-upstream-branch)" ]] && local same_branch_name=true || true
|
||||
local same_branch_name=
|
||||
[[ "$(_git-branch)" == "$(_git-upstream-branch)" ]] && same_branch_name=true
|
||||
if ([[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "auto" ]] && [[ "$(_git-num-remotes)" -ge 2 ]]) ||
|
||||
[[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "true" ]]; then
|
||||
if [[ "${same_branch_name}" != "true" ]]; then
|
||||
|
||||
27
themes/norbu/norbu.theme.bash
Normal file
27
themes/norbu/norbu.theme.bash
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function set_prompt_symbol () {
|
||||
if test $1 -eq 0 ; then
|
||||
PROMPT_SYMBOL=">_"
|
||||
else
|
||||
PROMPT_SYMBOL="${orange}>_${normal}"
|
||||
fi
|
||||
}
|
||||
function prompt_command() {
|
||||
set_prompt_symbol $?
|
||||
if test -z "$VIRTUAL_ENV" ; then
|
||||
PYTHON_VIRTUALENV=""
|
||||
else
|
||||
PYTHON_VIRTUALENV="${bold_yellow}[`basename \"$VIRTUAL_ENV\"`]"
|
||||
fi
|
||||
|
||||
PS1="${bold_orange}${PYTHON_VIRTUALENV}${reset_color}${bold_green}[\w]${bold_blue}\[$(scm_prompt_info)\]${normal} \n${PROMPT_SYMBOL} "
|
||||
}
|
||||
|
||||
# scm themeing
|
||||
SCM_THEME_PROMPT_DIRTY=" ✗"
|
||||
SCM_THEME_PROMPT_CLEAN=" ✓"
|
||||
SCM_THEME_PROMPT_PREFIX="["
|
||||
SCM_THEME_PROMPT_SUFFIX="]"
|
||||
|
||||
safe_append_prompt_command prompt_command
|
||||
45
themes/p4helpers.theme.bash
Normal file
45
themes/p4helpers.theme.bash
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function _p4-opened {
|
||||
timeout 2.0s p4 opened -s 2> /dev/null
|
||||
}
|
||||
|
||||
function _p4-opened-counts {
|
||||
# Return the following counts seperated by tabs:
|
||||
# - count of opened files
|
||||
# - count of pending changesets (other than defaults)
|
||||
# - count of files in the default changeset
|
||||
# - count of opened files in add mode
|
||||
# - count of opened files in edit mode
|
||||
# - count of opened files in delete mode
|
||||
_p4-opened | awk '
|
||||
BEGIN {
|
||||
opened=0;
|
||||
type_array["edit"]=0;
|
||||
type_array["add"]=0;
|
||||
type_array["delete"]=0;
|
||||
change_array["change"]=0;
|
||||
}
|
||||
{
|
||||
# p4 opened prints one file per line, and all lines begin with "//"
|
||||
# Here is an examples:
|
||||
#
|
||||
# $ p4 opened
|
||||
# //depot/some/file.py#4 - edit change 716431 (text)
|
||||
# //depot/another/file.py - edit default change (text)
|
||||
# //now/add/a/newfile.sh - add change 435645 (text+k)
|
||||
#
|
||||
#
|
||||
if ($1 ~ /^\/\//) {
|
||||
opened += 1
|
||||
change_array[$5] += 1
|
||||
type_array[$3] += 1
|
||||
}
|
||||
}
|
||||
END {
|
||||
default_changes=change_array["change"];
|
||||
non_default_changes=length(change_array) - 1;
|
||||
print opened "\t" non_default_changes "\t" default_changes "\t" type_array["add"] "\t" type_array["edit"] "\t" type_array["delete"]
|
||||
}
|
||||
'
|
||||
}
|
||||
@@ -46,14 +46,20 @@ The time/date is printed by the `date` command, so refer to its man page to chan
|
||||
|
||||
The contents of both prompt sides can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are:
|
||||
|
||||
* battery
|
||||
* clock
|
||||
* cwd
|
||||
* in_vim
|
||||
* python_venv
|
||||
* ruby
|
||||
* scm
|
||||
* user_info
|
||||
* `aws_profile` - Show the current value of the `AWS_PROFILE` environment variable
|
||||
* `battery` - Battery information (you'll need to enable the `battery` plugin)
|
||||
* `clock` - Current time in `HH:MM:SS` format
|
||||
* `cwd` - Current working directory including full folder hierarchy (c.f. `wd`)
|
||||
* `hostname` - Host name of machine
|
||||
* `in_vim` - Show identifier if running in `:terminal` from vim
|
||||
* `last_status` - Exit status of last run command
|
||||
* `python_venv` - Python virtual environment information (`virtualenv`, `venv`
|
||||
and `conda` supported)
|
||||
* `ruby` - Current ruby version if using `rvm`
|
||||
* `scm` - Version control information, `git`
|
||||
* `user_info` - Current user
|
||||
* `wd` - Working directory, like `cwd` but doesn't show the full folder
|
||||
hierarchy, only the directory you're currently in.
|
||||
|
||||
Two variables can be defined to set the order of the prompt segments:
|
||||
|
||||
|
||||
@@ -46,11 +46,13 @@ function __powerline_prompt_command {
|
||||
|
||||
## right prompt ##
|
||||
if [[ -n "${POWERLINE_RIGHT_PROMPT}" ]]; then
|
||||
LEFT_PROMPT+="${move_cursor_rightmost}"
|
||||
# LEFT_PROMPT+="${move_cursor_rightmost}"
|
||||
for segment in $POWERLINE_RIGHT_PROMPT; do
|
||||
local info="$(__powerline_${segment}_prompt)"
|
||||
[[ -n "${info}" ]] && __powerline_right_segment "${info}"
|
||||
done
|
||||
RIGHT_PAD=$(printf "%.s " $(seq 1 $RIGHT_PROMPT_LENGTH))
|
||||
LEFT_PROMPT+="${RIGHT_PAD}${move_cursor_rightmost}"
|
||||
LEFT_PROMPT+="\033[${RIGHT_PROMPT_LENGTH}D"
|
||||
fi
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ PYTHON_VENV_THEME_PROMPT_COLOR=35
|
||||
|
||||
SCM_NONE_CHAR=""
|
||||
SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "}
|
||||
SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "}
|
||||
SCM_THEME_PROMPT_CLEAN=""
|
||||
SCM_THEME_PROMPT_DIRTY=""
|
||||
SCM_THEME_PROMPT_CLEAN_COLOR=25
|
||||
@@ -35,6 +36,9 @@ RBENV_THEME_PROMPT_SUFFIX=""
|
||||
RUBY_THEME_PROMPT_COLOR=161
|
||||
RUBY_CHAR=${POWERLINE_RUBY_CHAR:="❲r❳ "}
|
||||
|
||||
AWS_PROFILE_CHAR="${POWERLINE_AWS_PROFILE_CHAR:=❲aws❳ }"
|
||||
AWS_PROFILE_PROMPT_COLOR=208
|
||||
|
||||
CWD_THEME_PROMPT_COLOR=240
|
||||
|
||||
LAST_STATUS_THEME_PROMPT_COLOR=196
|
||||
@@ -51,6 +55,8 @@ THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
|
||||
IN_VIM_THEME_PROMPT_COLOR=245
|
||||
IN_VIM_THEME_PROMPT_TEXT="vim"
|
||||
|
||||
HOST_THEME_PROMPT_COLOR=0
|
||||
|
||||
POWERLINE_LEFT_PROMPT=${POWERLINE_LEFT_PROMPT:="scm python_venv ruby cwd"}
|
||||
POWERLINE_RIGHT_PROMPT=${POWERLINE_RIGHT_PROMPT:="in_vim clock battery user_info"}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ A colorful theme, where shows a lot information about your shell session.
|
||||
* An indicator when the current shell is inside the Vim editor
|
||||
* Battery charging status (depends on the [../../plugins/available/battery.plugin.bash](battery plugin))
|
||||
* SCM Repository status (e.g. Git, SVN)
|
||||
* The current Kubernetes environment
|
||||
* The current Python environment (Virtualenv, venv, and Conda are supported) in use
|
||||
* The current Ruby environment (rvm and rbenv are supported) in use
|
||||
* Last command exit code (only shown when the exit code is greater than 0)
|
||||
@@ -42,16 +43,23 @@ The time/date is printed by the `date` command, so refer to its man page to chan
|
||||
|
||||
The contents of the prompt can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are:
|
||||
|
||||
* battery
|
||||
* clock
|
||||
* cwd
|
||||
* in_vim
|
||||
* python_venv
|
||||
* ruby
|
||||
* scm
|
||||
* user_info
|
||||
* `aws_profile` - Show the current value of the `AWS_PROFILE` environment variable
|
||||
* `battery` - Battery information (you'll need to enable the `battery` plugin)
|
||||
* `clock` - Current time in `HH:MM:SS` format
|
||||
* `cwd` - Current working directory including full folder hierarchy (c.f. `wd`)
|
||||
* `hostname` - Host name of machine
|
||||
* `in_vim` - Show identifier if running in `:terminal` from vim
|
||||
* `k8s_context` - Show current kubernetes context
|
||||
* `last_status` - Exit status of last run command
|
||||
* `python_venv` - Python virtual environment information (`virtualenv`, `venv`
|
||||
and `conda` supported)
|
||||
* `ruby` - Current ruby version if using `rvm`
|
||||
* `scm` - Version control information, `git`
|
||||
* `user_info` - Current user
|
||||
* `wd` - Working directory, like `cwd` but doesn't show the full folder
|
||||
hierarchy, only the directory you're currently in.
|
||||
|
||||
A variables can be defined to set the order of the prompt segments:
|
||||
A variable can be defined to set the order of the prompt segments:
|
||||
|
||||
POWERLINE_PROMPT="user_info scm python_venv ruby cwd"
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ function __powerline_left_segment {
|
||||
local OLD_IFS="${IFS}"; IFS="|"
|
||||
local params=( $1 )
|
||||
IFS="${OLD_IFS}"
|
||||
local separator_char=""
|
||||
local separator_char="${POWERLINE_LEFT_SEPARATOR}"
|
||||
local separator=""
|
||||
|
||||
if [[ "${SEGMENTS_AT_LEFT}" -gt 0 ]]; then
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
POWERLINE_LEFT_SEPARATOR=${POWERLINE_LEFT_SEPARATOR:=""}
|
||||
|
||||
. "$BASH_IT/themes/powerline-naked/powerline-naked.base.bash"
|
||||
|
||||
PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:=""}
|
||||
POWERLINE_LEFT_SEPARATOR=${POWERLINE_LEFT_SEPARATOR:=""}
|
||||
|
||||
USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "}
|
||||
USER_INFO_THEME_PROMPT_COLOR=240
|
||||
@@ -15,6 +16,7 @@ PYTHON_VENV_THEME_PROMPT_COLOR=35
|
||||
|
||||
SCM_NONE_CHAR=""
|
||||
SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "}
|
||||
SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "}
|
||||
SCM_THEME_PROMPT_CLEAN=""
|
||||
SCM_THEME_PROMPT_DIRTY=""
|
||||
SCM_THEME_PROMPT_COLOR=238
|
||||
@@ -31,6 +33,12 @@ RBENV_THEME_PROMPT_SUFFIX=""
|
||||
RUBY_THEME_PROMPT_COLOR=161
|
||||
RUBY_CHAR=${POWERLINE_RUBY_CHAR:="❲r❳ "}
|
||||
|
||||
KUBERNETES_CONTEXT_THEME_CHAR=${POWERLINE_KUBERNETES_CONTEXT_CHAR:="⎈ "}
|
||||
KUBERNETES_CONTEXT_THEME_PROMPT_COLOR=26
|
||||
|
||||
AWS_PROFILE_CHAR="${POWERLINE_AWS_PROFILE_CHAR:=❲aws❳ }"
|
||||
AWS_PROFILE_PROMPT_COLOR=208
|
||||
|
||||
CWD_THEME_PROMPT_COLOR=254
|
||||
|
||||
LAST_STATUS_THEME_PROMPT_COLOR=124
|
||||
@@ -47,6 +55,8 @@ THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
|
||||
IN_VIM_THEME_PROMPT_COLOR=245
|
||||
IN_VIM_THEME_PROMPT_TEXT="vim"
|
||||
|
||||
HOST_THEME_PROMPT_COLOR=254
|
||||
|
||||
POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"}
|
||||
|
||||
safe_append_prompt_command __powerline_prompt_command
|
||||
|
||||
@@ -12,6 +12,7 @@ A colorful theme, where shows a lot information about your shell session.
|
||||
* An indicator when the current shell is inside the Vim editor
|
||||
* Battery charging status (depends on the [../../plugins/available/battery.plugin.bash](battery plugin))
|
||||
* SCM Repository status (e.g. Git, SVN)
|
||||
* The current Kubernetes environment
|
||||
* The current Python environment (Virtualenv, venv, and Conda are supported) in use
|
||||
* The current Ruby environment (rvm and rbenv are supported) in use
|
||||
* Last command exit code (only shown when the exit code is greater than 0)
|
||||
@@ -40,16 +41,23 @@ The time/date is printed by the `date` command, so refer to its man page to chan
|
||||
|
||||
The contents of the prompt can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are:
|
||||
|
||||
* battery
|
||||
* clock
|
||||
* cwd
|
||||
* in_vim
|
||||
* python_venv
|
||||
* ruby
|
||||
* scm
|
||||
* user_info
|
||||
* `aws_profile` - Show the current value of the `AWS_PROFILE` environment variable
|
||||
* `battery` - Battery information (you'll need to enable the `battery` plugin)
|
||||
* `clock` - Current time in `HH:MM:SS` format
|
||||
* `cwd` - Current working directory including full folder hierarchy (c.f. `wd`)
|
||||
* `hostname` - Host name of machine
|
||||
* `in_vim` - Show identifier if running in `:terminal` from vim
|
||||
* `k8s_context` - Show current kubernetes context
|
||||
* `last_status` - Exit status of last run command
|
||||
* `python_venv` - Python virtual environment information (`virtualenv`, `venv`
|
||||
and `conda` supported)
|
||||
* `ruby` - Current ruby version if using `rvm`
|
||||
* `scm` - Version control information, `git`
|
||||
* `user_info` - Current user
|
||||
* `wd` - Working directory, like `cwd` but doesn't show the full folder
|
||||
hierarchy, only the directory you're currently in.
|
||||
|
||||
A variables can be defined to set the order of the prompt segments:
|
||||
A variable can be defined to set the order of the prompt segments:
|
||||
|
||||
POWERLINE_PROMPT="user_info scm python_venv ruby cwd"
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ PYTHON_VENV_THEME_PROMPT_COLOR=35
|
||||
|
||||
SCM_NONE_CHAR=""
|
||||
SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:="⎇ "}
|
||||
SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "}
|
||||
SCM_THEME_PROMPT_CLEAN=""
|
||||
SCM_THEME_PROMPT_DIRTY=""
|
||||
SCM_THEME_PROMPT_CLEAN_COLOR=25
|
||||
@@ -25,7 +26,13 @@ RVM_THEME_PROMPT_SUFFIX=""
|
||||
RBENV_THEME_PROMPT_PREFIX=""
|
||||
RBENV_THEME_PROMPT_SUFFIX=""
|
||||
RUBY_THEME_PROMPT_COLOR=161
|
||||
RUBY_CHAR=${POWERLINE_RUBY_CHAR:="ⓔ "}
|
||||
RUBY_CHAR=${POWERLINE_RUBY_CHAR:="💎 "}
|
||||
|
||||
KUBERNETES_CONTEXT_THEME_CHAR=${POWERLINE_KUBERNETES_CONTEXT_CHAR:="⎈ "}
|
||||
KUBERNETES_CONTEXT_THEME_PROMPT_COLOR=26
|
||||
|
||||
AWS_PROFILE_CHAR="${POWERLINE_AWS_PROFILE_CHAR:=❲aws❳ }"
|
||||
AWS_PROFILE_PROMPT_COLOR=208
|
||||
|
||||
CWD_THEME_PROMPT_COLOR=240
|
||||
|
||||
@@ -43,6 +50,8 @@ THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
|
||||
IN_VIM_THEME_PROMPT_COLOR=245
|
||||
IN_VIM_THEME_PROMPT_TEXT="vim"
|
||||
|
||||
HOST_THEME_PROMPT_COLOR=0
|
||||
|
||||
POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"}
|
||||
|
||||
safe_append_prompt_command __powerline_prompt_command
|
||||
|
||||
@@ -16,6 +16,7 @@ A colorful theme, where shows a lot information about your shell session.
|
||||
* An indicator when the current shell is inside the Vim editor
|
||||
* Battery charging status (depends on the [../../plugins/available/battery.plugin.bash](battery plugin))
|
||||
* SCM Repository status (e.g. Git, SVN)
|
||||
* The current Kubernetes environment
|
||||
* The current Python environment (Virtualenv, venv, and Conda are supported) in use
|
||||
* The current Ruby environment (rvm and rbenv are supported) in use
|
||||
* Last command exit code (only shown when the exit code is greater than 0)
|
||||
@@ -44,16 +45,23 @@ The time/date is printed by the `date` command, so refer to its man page to chan
|
||||
|
||||
The contents of the prompt can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are:
|
||||
|
||||
* battery
|
||||
* clock
|
||||
* cwd
|
||||
* in_vim
|
||||
* python_venv
|
||||
* ruby
|
||||
* scm
|
||||
* user_info
|
||||
* `aws_profile` - Show the current value of the `AWS_PROFILE` environment variable
|
||||
* `battery` - Battery information (you'll need to enable the `battery` plugin)
|
||||
* `clock` - Current time in `HH:MM:SS` format
|
||||
* `cwd` - Current working directory including full folder hierarchy (c.f. `wd`)
|
||||
* `hostname` - Host name of machine
|
||||
* `in_vim` - Show identifier if running in `:terminal` from vim
|
||||
* `k8s_context` - Show current kubernetes context
|
||||
* `last_status` - Exit status of last run command
|
||||
* `python_venv` - Python virtual environment information (`virtualenv`, `venv`
|
||||
and `conda` supported)
|
||||
* `ruby` - Current ruby version if using `rvm`
|
||||
* `scm` - Version control information, `git`
|
||||
* `user_info` - Current user
|
||||
* `wd` - Working directory, like `cwd` but doesn't show the full folder
|
||||
hierarchy, only the directory you're currently in.
|
||||
|
||||
A variables can be defined to set the order of the prompt segments:
|
||||
A variable can be defined to set the order of the prompt segments:
|
||||
|
||||
POWERLINE_PROMPT="user_info scm python_venv ruby cwd"
|
||||
|
||||
|
||||
@@ -52,6 +52,16 @@ function __powerline_ruby_prompt {
|
||||
[[ -n "${ruby_version}" ]] && echo "${RUBY_CHAR}${ruby_version}|${RUBY_THEME_PROMPT_COLOR}"
|
||||
}
|
||||
|
||||
function __powerline_k8s_context_prompt {
|
||||
local kubernetes_context=""
|
||||
|
||||
if _command_exists kubectl; then
|
||||
kubernetes_context="$(k8s_context_prompt)"
|
||||
fi
|
||||
|
||||
[[ -n "${kubernetes_context}" ]] && echo "${KUBERNETES_CONTEXT_THEME_CHAR}${kubernetes_context}|${KUBERNETES_CONTEXT_THEME_PROMPT_COLOR}"
|
||||
}
|
||||
|
||||
function __powerline_python_venv_prompt {
|
||||
set +u
|
||||
local python_venv=""
|
||||
@@ -84,6 +94,10 @@ function __powerline_scm_prompt {
|
||||
fi
|
||||
if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then
|
||||
scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
|
||||
elif [[ "${SCM_P4_CHAR}" == "${SCM_CHAR}" ]]; then
|
||||
scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
|
||||
elif [[ "${SCM_HG_CHAR}" == "${SCM_CHAR}" ]]; then
|
||||
scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
|
||||
fi
|
||||
echo "${scm_prompt}${scm}|${color}"
|
||||
fi
|
||||
@@ -132,6 +146,12 @@ function __powerline_in_vim_prompt {
|
||||
fi
|
||||
}
|
||||
|
||||
function __powerline_aws_profile_prompt {
|
||||
if [[ -n "${AWS_PROFILE}" ]]; then
|
||||
echo "${AWS_PROFILE_CHAR}${AWS_PROFILE}|${AWS_PROFILE_PROMPT_COLOR}"
|
||||
fi
|
||||
}
|
||||
|
||||
function __powerline_left_segment {
|
||||
local OLD_IFS="${IFS}"; IFS="|"
|
||||
local params=( $1 )
|
||||
|
||||
@@ -15,6 +15,7 @@ PYTHON_VENV_THEME_PROMPT_COLOR=35
|
||||
|
||||
SCM_NONE_CHAR=""
|
||||
SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "}
|
||||
SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "}
|
||||
SCM_THEME_PROMPT_CLEAN=""
|
||||
SCM_THEME_PROMPT_DIRTY=""
|
||||
SCM_THEME_PROMPT_CLEAN_COLOR=25
|
||||
@@ -30,6 +31,12 @@ RBENV_THEME_PROMPT_SUFFIX=""
|
||||
RUBY_THEME_PROMPT_COLOR=161
|
||||
RUBY_CHAR=${POWERLINE_RUBY_CHAR:="❲r❳ "}
|
||||
|
||||
KUBERNETES_CONTEXT_THEME_CHAR=${POWERLINE_KUBERNETES_CONTEXT_CHAR:="⎈ "}
|
||||
KUBERNETES_CONTEXT_THEME_PROMPT_COLOR=26
|
||||
|
||||
AWS_PROFILE_CHAR="${POWERLINE_AWS_PROFILE_CHAR:=❲aws❳ }"
|
||||
AWS_PROFILE_PROMPT_COLOR=208
|
||||
|
||||
CWD_THEME_PROMPT_COLOR=240
|
||||
|
||||
LAST_STATUS_THEME_PROMPT_COLOR=52
|
||||
@@ -46,6 +53,8 @@ THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
|
||||
IN_VIM_THEME_PROMPT_COLOR=245
|
||||
IN_VIM_THEME_PROMPT_TEXT="vim"
|
||||
|
||||
HOST_THEME_PROMPT_COLOR=0
|
||||
|
||||
POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"}
|
||||
|
||||
safe_append_prompt_command __powerline_prompt_command
|
||||
|
||||
185
themes/powerturk/powerturk.theme.bash
Normal file
185
themes/powerturk/powerturk.theme.bash
Normal file
@@ -0,0 +1,185 @@
|
||||
#!/usr/bin/env bash
|
||||
# Power-Turk theme for bash-it
|
||||
# Author (C) 2015 Ahmed Seref Guneysu
|
||||
|
||||
THEME_PROMPT_SEPARATOR=""
|
||||
|
||||
SHELL_SSH_CHAR=" "
|
||||
SHELL_THEME_PROMPT_COLOR=2
|
||||
SHELL_SSH_THEME_PROMPT_COLOR=208
|
||||
|
||||
VIRTUALENV_CHAR="ⓔ "
|
||||
VIRTUALENV_THEME_PROMPT_COLOR=35
|
||||
|
||||
SCM_NONE_CHAR=""
|
||||
|
||||
SCM_GIT_CHAR=" " # " "
|
||||
|
||||
SCM_THEME_PROMPT_CLEAN=""
|
||||
SCM_THEME_PROMPT_DIRTY=""
|
||||
|
||||
SCM_THEME_PROMPT_COLOR=16
|
||||
SCM_THEME_PROMPT_CLEAN_COLOR=231
|
||||
SCM_THEME_PROMPT_DIRTY_COLOR=196
|
||||
SCM_THEME_PROMPT_STAGED_COLOR=220
|
||||
SCM_THEME_PROMPT_UNSTAGED_COLOR=166
|
||||
|
||||
CWD_THEME_PROMPT_COLOR=240
|
||||
|
||||
LAST_STATUS_THEME_PROMPT_COLOR=52
|
||||
|
||||
_collapsed_wd() {
|
||||
# echo -e "\u2771\u276d\u276f"
|
||||
echo $(pwd | perl -pe "
|
||||
BEGIN {
|
||||
binmode STDIN, ':encoding(UTF-8)';
|
||||
binmode STDOUT, ':encoding(UTF-8)';
|
||||
}; s|^$HOME|<HOME>|g; s|/([^/])[^/]*(?=/)|/\$1|g") | \
|
||||
sed -re "s/\// /g"
|
||||
}
|
||||
|
||||
_swd(){
|
||||
# Adapted from http://stackoverflow.com/a/2951707/1766716
|
||||
begin="" # The unshortened beginning of the path.
|
||||
shortbegin="" # The shortened beginning of the path.
|
||||
current="" # The section of the path we're currently working on.
|
||||
end="${2:-$(pwd)}/" # The unmodified rest of the path.
|
||||
|
||||
if [[ "$end" =~ "$HOME" ]]; then
|
||||
INHOME=1
|
||||
end="${end#$HOME}" #strip /home/username from start of string
|
||||
begin="$HOME" #start expansion from the right spot
|
||||
else
|
||||
INHOME=0
|
||||
fi
|
||||
|
||||
end="${end#/}" # Strip the first /
|
||||
shortenedpath="$end" # The whole path, to check the length.
|
||||
maxlength="${1:-0}"
|
||||
|
||||
shopt -q nullglob && NGV="-s" || NGV="-u" # Store the value for later.
|
||||
shopt -s nullglob # Without this, anything that doesn't exist in the filesystem turns into */*/*/...
|
||||
|
||||
while [[ "$end" ]] && (( ${#shortenedpath} > maxlength ))
|
||||
do
|
||||
current="${end%%/*}" # everything before the first /
|
||||
end="${end#*/}" # everything after the first /
|
||||
|
||||
shortcur="$current"
|
||||
shortcurstar="$current" # No star if we don't shorten it.
|
||||
|
||||
for ((i=${#current}-2; i>=0; i--)); do
|
||||
subcurrent="${current:0:i}"
|
||||
matching=("$begin/$subcurrent"*) # Array of all files that start with $subcurrent.
|
||||
(( ${#matching[*]} != 1 )) && break # Stop shortening if more than one file matches.
|
||||
shortcur="$subcurrent"
|
||||
shortcurstar="$subcurrent*"
|
||||
done
|
||||
|
||||
#advance
|
||||
begin="$begin/$current"
|
||||
shortbegin="$shortbegin/$shortcurstar"
|
||||
shortenedpath="$shortbegin/$end"
|
||||
done
|
||||
|
||||
shortenedpath="${shortenedpath%/}" # strip trailing /
|
||||
shortenedpath="${shortenedpath#/}" # strip leading /
|
||||
|
||||
# Replaces slashes with except first occurence.
|
||||
if [ $INHOME -eq 1 ]; then
|
||||
echo "~/$shortenedpath" | sed "s/\///2g" # make sure it starts with ~/
|
||||
else
|
||||
echo "/$shortenedpath" | sed "s/\///2g" # Make sure it starts with /
|
||||
fi
|
||||
|
||||
shopt "$NGV" nullglob # Reset nullglob in case this is being used as a function.
|
||||
|
||||
}
|
||||
function set_rgb_color {
|
||||
if [[ "${1}" != "-" ]]; then
|
||||
fg="38;5;${1}"
|
||||
fi
|
||||
if [[ "${2}" != "-" ]]; then
|
||||
bg="48;5;${2}"
|
||||
[[ -n "${fg}" ]] && bg=";${bg}"
|
||||
fi
|
||||
echo -e "\[\033[${fg}${bg}m\]"
|
||||
}
|
||||
|
||||
function powerline_shell_prompt {
|
||||
if [[ -n "${SSH_CLIENT}" ]]; then
|
||||
SHELL_PROMPT="${bold_white}$(set_rgb_color - ${SHELL_SSH_THEME_PROMPT_COLOR}) ${SHELL_SSH_CHAR}\u@\h ${normal}"
|
||||
LAST_THEME_COLOR=${SHELL_SSH_THEME_PROMPT_COLOR}
|
||||
else
|
||||
SHELL_PROMPT="${bold_white}$(set_rgb_color - ${SHELL_THEME_PROMPT_COLOR}) ${normal}"
|
||||
LAST_THEME_COLOR=${SHELL_THEME_PROMPT_COLOR}
|
||||
fi
|
||||
}
|
||||
|
||||
function powerline_virtualenv_prompt {
|
||||
local environ=""
|
||||
|
||||
if [[ -n "$CONDA_DEFAULT_ENV" ]]; then
|
||||
environ="conda: $CONDA_DEFAULT_ENV"
|
||||
elif [[ -n "$VIRTUAL_ENV" ]]; then
|
||||
environ=$(basename "$VIRTUAL_ENV")
|
||||
fi
|
||||
|
||||
if [[ -n "$environ" ]]; then
|
||||
VIRTUALENV_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${VIRTUALENV_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${VIRTUALENV_THEME_PROMPT_COLOR}) ${VIRTUALENV_CHAR}$environ ${normal}"
|
||||
LAST_THEME_COLOR=${VIRTUALENV_THEME_PROMPT_COLOR}
|
||||
else
|
||||
VIRTUALENV_PROMPT=""
|
||||
fi
|
||||
}
|
||||
|
||||
function powerline_scm_prompt {
|
||||
scm_prompt_vars
|
||||
|
||||
if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then
|
||||
if [[ "${SCM_DIRTY}" -eq 3 ]]; then
|
||||
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_STAGED_COLOR} ${SCM_THEME_PROMPT_COLOR})"
|
||||
elif [[ "${SCM_DIRTY}" -eq 2 ]]; then
|
||||
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_UNSTAGED_COLOR} ${SCM_THEME_PROMPT_COLOR})"
|
||||
elif [[ "${SCM_DIRTY}" -eq 1 ]]; then
|
||||
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_DIRTY_COLOR} ${SCM_THEME_PROMPT_COLOR})"
|
||||
else
|
||||
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_CLEAN_COLOR} ${SCM_THEME_PROMPT_COLOR})"
|
||||
fi
|
||||
if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then
|
||||
SCM_PROMPT+=" ${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
|
||||
fi
|
||||
SCM_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${SCM_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${SCM_PROMPT} ${normal}"
|
||||
LAST_THEME_COLOR=${SCM_THEME_PROMPT_COLOR}
|
||||
else
|
||||
SCM_PROMPT=""
|
||||
fi
|
||||
}
|
||||
|
||||
function powerline_cwd_prompt {
|
||||
CWD_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${CWD_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}$(set_rgb_color 0 ${CWD_THEME_PROMPT_COLOR}) $(_swd)${normal}$(set_rgb_color ${CWD_THEME_PROMPT_COLOR} -)${normal}"
|
||||
LAST_THEME_COLOR=${CWD_THEME_PROMPT_COLOR}
|
||||
}
|
||||
|
||||
function powerline_last_status_prompt {
|
||||
if [[ "$1" -eq 0 ]]; then
|
||||
LAST_STATUS_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}"
|
||||
else
|
||||
LAST_STATUS_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${LAST_STATUS_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${LAST_STATUS_THEME_PROMPT_COLOR}) ${LAST_STATUS} ${normal}$(set_rgb_color ${LAST_STATUS_THEME_PROMPT_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}"
|
||||
fi
|
||||
}
|
||||
|
||||
function powerline_prompt_command() {
|
||||
local LAST_STATUS="$?"
|
||||
|
||||
powerline_shell_prompt
|
||||
powerline_virtualenv_prompt
|
||||
powerline_scm_prompt
|
||||
powerline_cwd_prompt
|
||||
powerline_last_status_prompt LAST_STATUS
|
||||
|
||||
PS1="${SHELL_PROMPT}${VIRTUALENV_PROMPT}${SCM_PROMPT}${CWD_PROMPT}${LAST_STATUS_PROMPT} "
|
||||
}
|
||||
|
||||
PROMPT_COMMAND=powerline_prompt_command
|
||||
|
||||
@@ -57,7 +57,12 @@ chroot(){
|
||||
|
||||
# show virtualenvwrapper
|
||||
my_ve(){
|
||||
if [ -n "$VIRTUAL_ENV" ]
|
||||
|
||||
if [ -n "$CONDA_DEFAULT_ENV" ]
|
||||
then
|
||||
my_ps_ve="${bold_purple}${CONDA_DEFAULT_ENV}${normal}";
|
||||
echo "($my_ps_ve)";
|
||||
elif [ -n "$VIRTUAL_ENV" ]
|
||||
then
|
||||
my_ps_ve="${bold_purple}$ve${normal}";
|
||||
echo "($my_ps_ve)";
|
||||
|
||||
Reference in New Issue
Block a user