Skip to content

Instantly share code, notes, and snippets.

@andreineculau
Last active August 21, 2021 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreineculau/04de265d9fe8b0e402fce1146592de97 to your computer and use it in GitHub Desktop.
Save andreineculau/04de265d9fe8b0e402fce1146592de97 to your computer and use it in GitHub Desktop.
my theme for liquidprompt
. /usr/local/share/liquidprompt
. path/to/lp_andreineculau.theme
lp_theme andreineculau
### ~/.liquidpromptrc
### NOTE customization at the bottom,
### on top of vanilla https://github.com/nojhan/liquidprompt/blob/master/liquidpromptrc-dist
####################################
# LIQUID PROMPT CONFIGURATION FILE #
####################################
# This example config file does not contain all possible config options, nor
# does it have detailed option descriptions. See the documentation for that:
# https://liquidprompt.readthedocs.io/en/stable/config.html
# If you want to use different themes and features,
# you can load the corresponding files here:
#source ~/.config/liquidprompt/nojhan.theme
#LP_PS1_FILE=~/.config/liquidprompt/nojhan.ps1
#############
# BEHAVIOUR #
#############
# Display the battery level in more urgent color when the level is below this threshold.
# Recommended value is 75
LP_BATTERY_THRESHOLD=75
# Display the load average over the past minute when above this threshold.
# This value is scaled per CPU, so on a quad-core machine, the load average
# would need to be 2.40 or greater to be displayed.
# Recommended value is 0.60
LP_LOAD_THRESHOLD=0.60
# Display the temperature when the temperate is above this threshold (in
# degrees Celsius).
# Recommended value is 60
LP_TEMP_THRESHOLD=60
# Use the shorten path feature if the path is too long to fit in the prompt
# line.
# Recommended value is 1
LP_ENABLE_SHORTEN_PATH=1
# The maximum percentage of the screen width used to display the path before
# removing the center portion of the path and replacing with '...'.
# Recommended value is 35
LP_PATH_LENGTH=35
# The number of directories (including '/') to keep at the beginning of a
# shortened path.
# Recommended value is 2
LP_PATH_KEEP=2
# Determine if the hostname should always be displayed, even if not connecting
# through network.
# Defaults to 0 (do not display hostname when locally connected)
# set to 1 if you want to always see the hostname
# set to -1 if you want to never see the hostname
LP_HOSTNAME_ALWAYS=0
# Use the fully qualified domain name (FQDN) instead of the short hostname when
# the hostname is displayed
LP_ENABLE_FQDN=0
# When to display the user name:
# 1: always display the user name
# 0: hide the logged user (always display different users)
# -1: never display the user name
# Default value is 1
LP_USER_ALWAYS=1
# Display the actual values of load/batteries along with their
# corresponding marks. Set to 0 to only print the colored marks.
# Defaults to 1 (display percentages)
LP_PERCENTS_ALWAYS=1
# Use the permissions feature and display a red ':' before the prompt to show
# when you don't have write permission to the current directory.
# Recommended value is 1
LP_ENABLE_PERM=1
# Enable the proxy detection feature.
# Recommended value is 1
LP_ENABLE_PROXY=1
# Enable the jobs feature.
# Recommended value is 1
LP_ENABLE_JOBS=1
# Enable the detached sessions feature.
# Default value is 1
LP_ENABLE_DETACHED_SESSIONS=1
# Enable the load feature.
# Recommended value is 1
LP_ENABLE_LOAD=1
# Enable the battery feature.
# Recommended value is 1
LP_ENABLE_BATT=1
# Enable the 'sudo credentials' feature.
# Be warned that this may pollute the syslog if you don't have sudo
# credentials, and the sysadmin might hate you.
LP_ENABLE_SUDO=0
# Enable the directory stack support.
LP_ENABLE_DIRSTACK=0
# Enable the VCS features with the root account.
# Recommended value is 0
LP_ENABLE_VCS_ROOT=0
# Enable the Git special features.
# Recommended value is 1
LP_ENABLE_GIT=1
# Enable the Subversion special features.
# Recommended value is 1
LP_ENABLE_SVN=1
# Enable the Mercurial special features.
# Recommended value is 1
LP_ENABLE_HG=1
# Enable the Fossil special features.
# Recommended value is 1
LP_ENABLE_FOSSIL=1
# Enable the Bazaar special features.
# Recommended value is 1
LP_ENABLE_BZR=1
# Show time of when the current prompt was displayed.
LP_ENABLE_TIME=0
# Show runtime of the previous command if over LP_RUNTIME_THRESHOLD
# Recommended value is 0
LP_ENABLE_RUNTIME=0
# Minimal runtime (in seconds) before the runtime will be displayed
# Recommended value is 2
LP_RUNTIME_THRESHOLD=2
# Ring the terminal bell if the runtime of the previous command exceeded
# LP_RUNTIME_BELL_THRESHOLD
# Recommended value is 0
LP_ENABLE_RUNTIME_BELL=0
# Minimal runtime (in seconds) before the terminal bell will be rung.
# Recommended value is 10
LP_RUNTIME_BELL_THRESHOLD=10
# Display the virtualenv that is currently activated, if any
# Recommended value is 1
LP_ENABLE_VIRTUALENV=1
# Display the ruby virtual env that is currently activated, if any
# Recommended value is 1
LP_ENABLE_RUBY_VENV=1
# If using RVM, personalize the rvm-prompt.
# see http://rvm.io/workflow/prompt for details.
# Warning, this variable must be a shell array.
LP_RUBY_RVM_PROMPT_OPTIONS=(i v g s)
# Display the terraform workspace that is currently activated, if any
# Recommended value is 0
LP_ENABLE_TERRAFORM=0
# Display the enabled software collections, if any
# Recommended value is 1
LP_ENABLE_SCLS=1
# Show current Kubernetes kubectl context
LP_ENABLE_KUBECONTEXT=0
# Delimiter to shorten kubectl context by removing a suffix.
# E.g. when your context names are dev-cluster and test-cluster, set to "-"
# in order to output "dev" and "test" in prompt.
LP_DELIMITER_KUBECONTEXT_SUFFIX=
# Delimiter to shorten kubectl context by removing a prefix.
# E.g. when your context names are like
# arn:aws:eks:$REGION:$ACCOUNT_ID:cluster/$CLUSTER_NAME, set to "/"
# in order to output "$CLUSTER_NAME" in prompt.
LP_DELIMITER_KUBECONTEXT_PREFIX=
# Display the current active AWS_PROFILE, if any
# Recommended value is 1
LP_ENABLE_AWS_PROFILE=1
# Show highest system temperature
LP_ENABLE_TEMP=1
# When showing the time, use an analog clock instead of numeric values.
# Recommended value is 0
LP_TIME_ANALOG=0
# Use the prompt as the title of the terminal window
# Recommended value is 0
LP_ENABLE_TITLE=0
# Enable Title for screen, byobu, and tmux
LP_ENABLE_SCREEN_TITLE=0
# Use different colors for the different hosts you SSH to
LP_ENABLE_SSH_COLORS=0
# Show the error code of the last command if it was not 0
LP_ENABLE_ERROR=1
# Specify an array of absolute paths in which all vcs will be disabled.
# Ex: ("/root" "/home/me/large-remove-svn-repo")
LP_DISABLED_VCS_PATHS=()
# Use a local liquidpromptrc if it exists.
# Can be helpful if you sync your primary config across machines, or if
# there's a system-wide config at /etc/liquidpromptrc from which you'd
# like to make only minor deviations.
#LOCAL_RCFILE=$HOME/.liquidpromptrc.local
#[ -f "$LOCAL_RCFILE" ] && source "$LOCAL_RCFILE"
# vim: set et sts=4 sw=4 tw=120 ft=sh:
########################################################################################################################
LP_ENABLE_SHORTEN_PATH=0
LP_HOSTNAME_ALWAYS=1
LP_ENABLE_TIME=1
LP_ENABLE_RUNTIME=1
LP_RUNTIME_THRESHOLD=0
LP_ENABLE_TEMP=1
LP_ENABLE_TITLE=1
LP_ENABLE_SCREEN_TITLE=1
LP_ENABLE_SSH_COLORS=1
LP_MARK_DIRSTACK="≡"
LP_ENABLE_DIRSTACK=0
LP_MARK_PERM=""
LP_ENABLE_PERM=0
_lp_andreineculau_theme_activate() {
_lp_default_theme_activate
}
_lp_andreineculau_theme_directory() {
_lp_default_theme_directory
}
_lp_andreineculau_theme_prompt() {
_lp_default_theme_prompt_data
# _lp_default_theme_prompt_template
PS1=$'\n'
PS1+="${LP_PS1_PREFIX}"
local PS1_MISC="${LP_ERR}${LP_RUNTIME} ${LP_TIME}${LP_JOBS}${LP_BATT}${LP_LOAD}${LP_TEMP}"
if (( _LP_SHELL_zsh )); then
RPROMPT="${PS1_MISC}"
else
PS1+="${LP_PS1_LINE_PREFIX:-}${PS1_MISC}${LP_PS1_LINE_POSTFIX:-}"
PS1+=$'\n'
fi
local MAYBE_SHLVL=${SHLVL}
[[ "${MAYBE_SHLVL}" != "1" ]] || MAYBE_SHLVL=" "
# PS1+="${LP_PS1_LINE_PREFIX:-}${MAYBE_SHLVL}${LP_PWD}${LP_PERM}${LP_DIRSTACK} as ${LP_USER}${LP_HOST}${LP_PS1_LINE_POSTFIX:-}"$'\n'
PS1+="${LP_PS1_LINE_PREFIX:-}${MAYBE_SHLVL}${LP_PWD} as ${LP_USER}${LP_HOST}${LP_PS1_LINE_POSTFIX:-}"$'\n'
local PS1_ENV="${LP_SCLS}${LP_AWS_PROFILE}${LP_VENV}${LP_RUBY_VENV}${LP_TFSPACE}${LP_KUBECONTEXT}${LP_PROXY}"
[[ -z "${PS1_ENV}" ]] || PS1+="${LP_PS1_LINE_PREFIX:-}${PS1_ENV}${LP_PS1_LINE_POSTFIX:-}"$'\n'
local PS1_VCS="${LP_VCS:1}"
if _lp_find_vcs; then
_lp_vcs_commit_id
PS1_VCS+=" ${lp_vcs_commit_id}"
if [[ "${lp_vcs_type}" = "git" ]]; then
local GIT_REF=$(git -C "${lp_vcs_root}" symbolic-ref -q HEAD 2>/dev/null | head -1 | sed "s/HEAD//")
PS1_VCS+=" $(git -C "${lp_vcs_root}" for-each-ref --format="%(upstream:short)" ${GIT_REF:-HEAD} 2>/dev/null)"
# local GIT_TRACK_REMOTE=$(git -C "${lp_vcs_root}" for-each-ref --format="%(upstream:short)" ${GIT_REF} 2>/dev/null | cut -d"/" -f1)
# if [[ -n "${GIT_TRACK_REMOTE}" ]]; then
# local GIT_TRACK_REMOTE_URL=$(git -C "${lp_vcs_root}" remote get-url ${GIT_TRACK_REMOTE})
# if [[ -n "${GIT_TRACK_REMOTE_URL}" ]] && [[ "${GIT_TRACK_REMOTE_URL}" =~ github\.com ]]; then
# local GITHUB_REPO=$(echo "${GIT_TRACK_REMOTE_URL}" | sed "s,.*github.com[:/],," | sed "s,\.git$,,")
# local GIT_HASH=$(git -C "${lp_vcs_root}" log -n 1 --pretty=format:%h 2>/dev/null)
# local GITHUB_STATUS_URL="https://api.github.com/repos/${GITHUB_REPO}/commits/${GIT_HASH}/status"
# local PS_GIT_HUB_CI_STATUS="$(curl -qfs -H "Accept: application/vnd.github.v3+json" ${GITHUB_STATUS_URL} | jq -r .state)"
# case ${PS_GIT_HUB_CI_STATUS} in
# "")
# ;;
# neutral,cancelled)
# PS_GIT_HUB_CI_STATUS="${GREY}CI:??${NORMAL}"
# ;;
# pending)
# PS_GIT_HUB_CI_STATUS="${GREY}CI:..${NORMAL}"
# ;;
# success)
# PS_GIT_HUB_CI_STATUS="${GREEN}CI:+1${NORMAL}"
# ;;
# *)
# # PS_GIT_HUB_CI_STATUS="${RED}!! $(hub ci-status -f '%U')${NORMAL}"
# PS_GIT_HUB_CI_STATUS="${RED}CI:${PS_GIT_HUB_CI_STATUS}${NORMAL}"
# ;;
# esac
# PS1_VCS+=" ${PS_GIT_HUB_CI_STATUS}"
# fi
# fi
fi
fi
[[ -z "${PS1_VCS}" ]] || PS1+="${LP_PS1_LINE_PREFIX:-}${PS1_VCS}${LP_PS1_LINE_POSTFIX:-}"$'\n'
PS1+="${LP_PS1_LINE_PREFIX:-}${LP_MARK_PREFIX:1}${LP_COLOR_MARK}${LP_MARK_DEFAULT} ${LP_PS1_LINE_POSTFIX:-}"
PS1+="${LP_PS1_POSTFIX}"
_lp_formatted_title "${LP_PS1_PREFIX}${LP_MARK_BRACKET_OPEN}${lp_username_raw-}${lp_hostname_raw+@}${lp_hostname_raw-}${LP_MARK_PERM}${lp_path-}${LP_MARK_BRACKET_CLOSE}${LP_MARK_PREFIX}${lp_smart_mark} ${LP_PS1_POSTFIX}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment