Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in_toolbox prompt to powerline themes #1716

Merged
merged 2 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions themes/gitline/gitline.theme.bash
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,8 @@ THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
IN_VIM_THEME_PROMPT_COLOR=245
IN_VIM_THEME_PROMPT_TEXT="vim"

IN_TOOLBOX_THEME_PROMPT_COLOR=125
IN_TOOLBOX_THEME_PROMPT_TEXT="⬢ "


safe_append_prompt_command __powerline_prompt_command
18 changes: 13 additions & 5 deletions themes/gitline/powerline.base.bash
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ function __powerline_cwd_prompt {
}

function __powerline_hostname_prompt {
local fg_color=206
local fg_color=206

echo "$(hostname -s)|${HOST_THEME_PROMPT_COLOR}|${fg_color}"
echo "$(hostname -s)|${HOST_THEME_PROMPT_COLOR}|${fg_color}"
}

function __powerline_wd_prompt {
local fg_color=206
local fg_color=206

echo "\W|${CWD_THEME_PROMPT_COLOR}|${fg_color}"
}
Expand Down Expand Up @@ -158,21 +158,29 @@ function __powerline_battery_prompt {
}

function __powerline_in_vim_prompt {
local fg_color=206
local fg_color=206

if [ -n "$VIMRUNTIME" ]; then
echo "${IN_VIM_THEME_PROMPT_TEXT}|${IN_VIM_THEME_PROMPT_COLOR}|${fg_color}"
fi
}

function __powerline_aws_profile_prompt {
local fg_color=206
local fg_color=206

if [[ -n "${AWS_PROFILE}" ]]; then
echo "${AWS_PROFILE_CHAR}${AWS_PROFILE}|${AWS_PROFILE_PROMPT_COLOR}|${fg_color}"
fi
}

function __powerline_in_toolbox_prompt {
local fg_color=206

if [ -f /run/.containerenv ] && [ -f /run/.toolboxenv ]; then
echo "${IN_TOOLBOX_THEME_PROMPT_TEXT}|${IN_TOOLBOX_THEME_PROMPT_COLOR}|${fg_color}"
fi
}

function __powerline_left_segment {
local OLD_IFS="${IFS}"; IFS="|"
local params=( $1 )
Expand Down
1 change: 1 addition & 0 deletions themes/powerline-multiline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ The contents of both prompt sides can be "reordered", all the "segments" (every
* `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_toolbox` - Show identifier if running inside a [toolbox](https://github.com/containers/toolbox)
* `in_vim` - Show identifier if running in `:terminal` from vim
* `k8s_context` - Show current kubernetes context
* `last_status` - Exit status of last run command
Expand Down
3 changes: 3 additions & 0 deletions themes/powerline-multiline/powerline-multiline.theme.bash
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
IN_VIM_THEME_PROMPT_COLOR=${POWERLINE_IN_VIM_COLOR:=245}
IN_VIM_THEME_PROMPT_TEXT=${POWERLINE_IN_VIM_TEXT:="vim"}

IN_TOOLBOX_THEME_PROMPT_COLOR=${POWERLINE_IN_TOOLBOX_COLOR:=125}
IN_TOOLBOX_THEME_PROMPT_TEXT=${POWERLINE_IN_TOOLBOX_TEXT:="⬢ "}

HOST_THEME_PROMPT_COLOR=${POWERLINE_HOST_COLOR:=0}

SHLVL_THEME_PROMPT_COLOR=${POWERLINE_SHLVL_COLOR:=${HOST_THEME_PROMPT_COLOR}}
Expand Down
1 change: 1 addition & 0 deletions themes/powerline-naked/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o
* `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_toolbox` - Show identifier if running inside a [toolbox](https://github.com/containers/toolbox)
* `in_vim` - Show identifier if running in `:terminal` from vim
* `k8s_context` - Show current kubernetes context
* `last_status` - Exit status of last run command
Expand Down
3 changes: 3 additions & 0 deletions themes/powerline-naked/powerline-naked.theme.bash
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
IN_VIM_THEME_PROMPT_COLOR=${POWERLINE_IN_VIM_COLOR:=245}
IN_VIM_THEME_PROMPT_TEXT=${POWERLINE_IN_VIM_TEXT:="vim"}

IN_TOOLBOX_THEME_PROMPT_COLOR=${POWERLINE_IN_TOOLBOX_COLOR:=125}
IN_TOOLBOX_THEME_PROMPT_TEXT=${POWERLINE_IN_TOOLBOX_TEXT:="⬢ "}

HOST_THEME_PROMPT_COLOR=${POWERLINE_HOST_COLOR:=254}

SHLVL_THEME_PROMPT_COLOR=${POWERLINE_SHLVL_COLOR:=${HOST_THEME_PROMPT_COLOR}}
Expand Down
1 change: 1 addition & 0 deletions themes/powerline-plain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o
* `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_toolbox` - Show identifier if running inside a [toolbox](https://github.com/containers/toolbox)
* `in_vim` - Show identifier if running in `:terminal` from vim
* `k8s_context` - Show current kubernetes context
* `last_status` - Exit status of last run command
Expand Down
3 changes: 3 additions & 0 deletions themes/powerline-plain/powerline-plain.theme.bash
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
IN_VIM_THEME_PROMPT_COLOR=${POWERLINE_IN_VIM_COLOR:=245}
IN_VIM_THEME_PROMPT_TEXT=${POWERLINE_IN_VIM_TEXT:="vim"}

IN_TOOLBOX_THEME_PROMPT_COLOR=${POWERLINE_IN_TOOLBOX_COLOR:=125}
IN_TOOLBOX_THEME_PROMPT_TEXT=${POWERLINE_IN_TOOLBOX_TEXT:="⬢ "}

HOST_THEME_PROMPT_COLOR=${POWERLINE_HOST_COLOR:=0}

SHLVL_THEME_PROMPT_COLOR=${POWERLINE_SHLVL_COLOR:=${HOST_THEME_PROMPT_COLOR}}
Expand Down
1 change: 1 addition & 0 deletions themes/powerline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o
* `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_toolbox` - Show identifier if running inside a [toolbox](https://github.com/containers/toolbox)
* `in_vim` - Show identifier if running in `:terminal` from vim
* `k8s_context` - Show current kubernetes context
* `last_status` - Exit status of last run command
Expand Down
6 changes: 6 additions & 0 deletions themes/powerline/powerline.base.bash
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ function __powerline_aws_profile_prompt() {
fi
}

function __powerline_in_toolbox_prompt() {
if [ -f /run/.containerenv ] && [ -f /run/.toolboxenv ]; then
echo "${IN_TOOLBOX_THEME_PROMPT_TEXT}|${IN_TOOLBOX_THEME_PROMPT_COLOR}"
fi
}

function __powerline_shlvl_prompt() {
if [[ "${SHLVL}" -gt 1 ]]; then
local prompt="${SHLVL_THEME_PROMPT_CHAR}"
Expand Down
3 changes: 3 additions & 0 deletions themes/powerline/powerline.theme.bash
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
IN_VIM_THEME_PROMPT_COLOR=${POWERLINE_IN_VIM_COLOR:=245}
IN_VIM_THEME_PROMPT_TEXT=${POWERLINE_IN_VIM_TEXT:="vim"}

IN_TOOLBOX_THEME_PROMPT_COLOR=${POWERLINE_IN_TOOLBOX_COLOR:=125}
IN_TOOLBOX_THEME_PROMPT_TEXT=${POWERLINE_IN_TOOLBOX_TEXT:="⬢ "}

HOST_THEME_PROMPT_COLOR=${POWERLINE_HOST_COLOR:=0}

SHLVL_THEME_PROMPT_COLOR=${POWERLINE_SHLVL_COLOR:=${HOST_THEME_PROMPT_COLOR}}
Expand Down
3 changes: 3 additions & 0 deletions themes/redline/redline.theme.bash
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
IN_VIM_THEME_PROMPT_COLOR=245
IN_VIM_THEME_PROMPT_TEXT="vim"

IN_TOOLBOX_THEME_PROMPT_COLOR=125
IN_TOOLBOX_THEME_PROMPT_TEXT="⬢ "

POWERLINE_PROMPT=${POWERLINE_PROMPT:="python_venv ruby user_info hostname cwd scm"}

safe_append_prompt_command __powerline_prompt_command