Skip to content

Commit

Permalink
feat(zsh): show nix status on prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
himkt committed Dec 2, 2024
1 parent d1c3a02 commit 3c43e02
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion zsh/config.d/zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ function current_timestamp () {
echo "[%{$fg_bold[blue]%}$(date +'%Y-%m-%d %H:%M:%S')%{${reset_color}%}]"
}

function current_nix () {
if [[ -v IN_NIX_SHELL ]]; then
echo "[%{$fg_bold[cyan]%}nix%{${reset_color}%}]"
fi
}

function parse_git_branch() {
(git symbolic-ref -q HEAD || git name-rev --name-only --no-undefined --always HEAD) 2> /dev/null
}
Expand Down Expand Up @@ -221,7 +227,7 @@ function current_git_status () {
}

LF=$'\n'
PROMPT='$(current_platform)$(current_context)$(current_path)$(current_git_status)${LF}> '
PROMPT='$(current_nix)$(current_platform)$(current_context)$(current_path)$(current_git_status)${LF}> '
RPROMPT='$(current_timestamp)'
SPROMPT="%{${fg[red]}%}%r is correct? [y, n, a, e]:%{${reset_color}%}"

Expand Down

0 comments on commit 3c43e02

Please sign in to comment.