From e43eb1177872f52e949fb5f0f93396ed94b0d093 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sun, 2 Aug 2026 14:48:29 +0200 Subject: move to chezmoi --- home/dot_local/share/bin/executable_prompt | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 home/dot_local/share/bin/executable_prompt (limited to 'home/dot_local/share/bin/executable_prompt') diff --git a/home/dot_local/share/bin/executable_prompt b/home/dot_local/share/bin/executable_prompt new file mode 100644 index 0000000..7dde932 --- /dev/null +++ b/home/dot_local/share/bin/executable_prompt @@ -0,0 +1,33 @@ +#!/bin/sh +fmt_esc() { + printf "%s$1%s" "$eo" "$ec" +} + +fmt_segment() { + content="$1" + [ -z "$content" ] && return + printf '%s%s%s -> %s' "$(fmt_esc '\e[90m')" "${content}" "$(fmt_esc '\e[30m')" "$(fmt_esc '\e[0m')" +} + +fmt_environment() { + content="$1" + [ -z "$content" ] && return + printf '%s(%s%s%s)%s ' "$(fmt_esc '\e[30;40m')" "$(fmt_esc '\e[97m')" "$content" "$(fmt_esc '\e[30;40m')" "$(fmt_esc '\e[0m')" +} + +[ -n "$1" ] && fmt_environment "$1" +fmt_environment "$VIRTUAL_ENV_PROMPT" + +# only display hostname in prompt if connected over SSH +[ -n "$SSH_CLIENT" ] && fmt_segment "$(hostname)" + +# current working directory +here="$PWD" +[ "$here" = "$HOME" ] && here="~" +fmt_segment "$(basename "$here")" + +# git status +git rev-parse --is-inside-work-tree 1> /dev/null 2> /dev/null && fmt_segment "git $(git rev-parse --abbrev-ref HEAD 2> /dev/null)" + +# exit happily +exit 0 -- cgit v1.2.3