diff --git a/.gitignore b/.gitignore index b748d384..a68b821e 100755 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ plugins/custom.plugins.bash .*.un~ bats .idea +*.sublime-workspace +*.sublime-project \ No newline at end of file diff --git a/themes/powerline/powerline.base.bash b/themes/powerline/powerline.base.bash index 3abeda8d..251c4ebb 100644 --- a/themes/powerline/powerline.base.bash +++ b/themes/powerline/powerline.base.bash @@ -10,16 +10,14 @@ function set_color { } function __powerline_user_info_prompt { - local user_info="" + local user_info=${USER} local color=${USER_INFO_THEME_PROMPT_COLOR} - if sudo -n uptime 2>&1 | grep -q "load"; then - color=${USER_INFO_THEME_PROMPT_COLOR_SUDO} - fi case "${POWERLINE_PROMPT_USER_INFO_MODE}" in "sudo") - if [[ "${color}" == "${USER_INFO_THEME_PROMPT_COLOR_SUDO}" ]]; then - user_info="!" + if sudo -n true >/dev/null 2>&1; then + color=${USER_INFO_THEME_PROMPT_COLOR_SUDO} + user_info=${USER_INFO_SUDO_CHAR}${USER} fi ;; *) @@ -82,7 +80,17 @@ function __powerline_scm_prompt { } function __powerline_cwd_prompt { - echo "$(pwd | sed "s|^${HOME}|~|")|${CWD_THEME_PROMPT_COLOR}" + local cwd=$(pwd | sed "s|^${HOME}|~|") + + #if [[ -n "${CWD_THEME_DIR_SEPARATOR}" ]]; then + # todo + #fi + + echo "${cwd}|${CWD_THEME_PROMPT_COLOR}" +} + +function __powerline_hostname_prompt { + echo "$(hostname -s)|${HOST_THEME_PROMPT_COLOR}" } function __powerline_clock_prompt { @@ -141,11 +149,17 @@ function __powerline_prompt_command { SEGMENTS_AT_LEFT=0 LAST_SEGMENT_COLOR="" + + if [[ -n "${POWERLINE_PROMPT_DISTRO_LOGO}" ]]; then + LEFT_PROMPT+="$(set_color ${PROMPT_DISTRO_LOGO_COLOR} ${PROMPT_DISTRO_LOGO_COLORBG})${PROMPT_DISTRO_LOGO}$(set_color - -)" + fi + ## left prompt ## for segment in $POWERLINE_PROMPT; do local info="$(__powerline_${segment}_prompt)" [[ -n "${info}" ]] && __powerline_left_segment "${info}" done + [[ "${last_status}" -ne 0 ]] && __powerline_left_segment $(__powerline_last_status_prompt ${last_status}) [[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_color ${LAST_SEGMENT_COLOR} -)${separator_char}${normal}" @@ -156,3 +170,4 @@ function __powerline_prompt_command { LEFT_PROMPT \ SEGMENTS_AT_LEFT } + diff --git a/themes/redline/README.md b/themes/redline/README.md new file mode 100644 index 00000000..0705612e --- /dev/null +++ b/themes/redline/README.md @@ -0,0 +1,43 @@ +# Redline Theme + +changed up the powerline base a little. + +It plays nicest with this font: [DroidSansMonoForPowerline](https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/DroidSansMono) + +Read the [powerline theme documentation](https://github.com/Bash-it/bash-it/blob/master/themes/powerline/README.md) + + +## added +* hostname +* distro logo + +## changed +* sudo credential check +* required font +* some icons + +Works real good like with: +```bash +## set the theme +export BASH_IT_THEME='redline' + +# Set this to false to turn off version control status checking within the prompt for all themes +export SCM_CHECK=true + +## Set Xterm/screen/Tmux title with only a short hostname. +export SHORT_HOSTNAME=$(hostname -s) + +## enable sudo prompt +export POWERLINE_PROMPT_USER_INFO_MODE="sudo" + +## prompt part string +export POWERLINE_PROMPT="python_venv user_info hostname cwd scm" + +``` + +## enable your distro logo with +```bash +export POWERLINE_PROMPT_DISTRO_LOGO="yes" +``` + +![screenshot](screenshot.png?raw=true) diff --git a/themes/redline/redline.theme.bash b/themes/redline/redline.theme.bash new file mode 100644 index 00000000..3d67e8a5 --- /dev/null +++ b/themes/redline/redline.theme.bash @@ -0,0 +1,60 @@ +#!/usr/bin/env bash + +. "$BASH_IT/themes/powerline/powerline.base.bash" + +PROMPT_DISTRO_LOGO=" " +PROMPT_DISTRO_LOGO_COLOR=15 +PROMPT_DISTRO_LOGO_COLORBG=52 + +PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:=""} +POWERLINE_LEFT_SEPARATOR=${POWERLINE_LEFT_SEPARATOR:=""} + +USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "} +USER_INFO_SUDO_CHAR=${POWERLINE_USER_INFO_SUDO_CHAR:=" "} +USER_INFO_THEME_PROMPT_COLOR=52 +USER_INFO_THEME_PROMPT_COLOR_SUDO=52 + +PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:=" "} +CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="❲c❳ "} +PYTHON_VENV_THEME_PROMPT_COLOR=23 + +SCM_NONE_CHAR="" +SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "} +SCM_THEME_PROMPT_CLEAN="" +SCM_THEME_PROMPT_DIRTY="" +SCM_THEME_PROMPT_CLEAN_COLOR=235 +SCM_THEME_PROMPT_DIRTY_COLOR=235 #124 +SCM_THEME_PROMPT_STAGED_COLOR=235 #52 +SCM_THEME_PROMPT_UNSTAGED_COLOR=88 +SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR} + +RVM_THEME_PROMPT_PREFIX="" +RVM_THEME_PROMPT_SUFFIX="" +RBENV_THEME_PROMPT_PREFIX="" +RBENV_THEME_PROMPT_SUFFIX="" +RUBY_THEME_PROMPT_COLOR=161 +RUBY_CHAR=${POWERLINE_RUBY_CHAR:=" "} + +CWD_THEME_DIR_SEPARATOR="" +CWD_THEME_DIR_SEPARATOR_COLOR=52 + +CWD_THEME_PROMPT_COLOR=238 +HOST_THEME_PROMPT_COLOR=88 + +LAST_STATUS_THEME_PROMPT_COLOR=52 + +CLOCK_THEME_PROMPT_COLOR=240 + +BATTERY_AC_CHAR=${BATTERY_AC_CHAR:="⚡"} +BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=70 +BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=208 +BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160 + +THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"} + +IN_VIM_THEME_PROMPT_COLOR=245 +IN_VIM_THEME_PROMPT_TEXT="vim" + +POWERLINE_PROMPT=${POWERLINE_PROMPT:="python_venv ruby user_info hostname cwd scm"} + +safe_append_prompt_command __powerline_prompt_command diff --git a/themes/redline/screenshot.png b/themes/redline/screenshot.png new file mode 100644 index 00000000..ba9df717 Binary files /dev/null and b/themes/redline/screenshot.png differ