From 0effaa91f4eb5676533db5d0238c7f3ad209d1ca Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Mon, 20 Jan 2025 16:45:10 +0100 Subject: add zsh prompt --- .config/zsh/prompt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .config/zsh/prompt (limited to '.config') 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)" + -- cgit v1.2.3