aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2025-01-20 16:45:10 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2025-01-20 16:45:10 +0100
commit0effaa91f4eb5676533db5d0238c7f3ad209d1ca (patch)
tree70a0b53d7f951c12b2b09387a10ec1931103e636
parent6031a7a9204f11c2acc44ab33552576375ba8c28 (diff)
add zsh prompt
-rw-r--r--.config/zsh/prompt22
1 files changed, 22 insertions, 0 deletions
diff --git a/.config/zsh/prompt b/.config/zsh/prompt
new file mode 100644
index 0000000..db66644
--- /dev/null
+++ b/.config/zsh/prompt
@@ -0,0 +1,22 @@
+#!/bin/zsh
+unset PROMPT
+setopt PROMPT_SUBST
+
+prompt_segment() {
+ content="$1"
+ [ -z "$content" ] && return
+ echo "%{\e[90m%}${content}%{\e[30m%} -> %{\e[0m%}"
+}
+
+prompt_mod_git_info() {
+ git rev-parse --is-inside-work-tree 1> /dev/null 2> /dev/null || return
+ prompt_segment "git $(git rev-parse --abbrev-ref HEAD)"
+}
+
+# only display hostname in prompt if connected over SSH
+[ -n "$SSH_CLIENT" ] && PROMPT+="$(prompt_segment '%m')"
+# working directory
+PROMPT+="$(prompt_segment '%c')"
+# git info (if in repo)
+PROMPT+="\$(prompt_mod_git_info)"
+