From 67d34d9ee5a7a1288c9048a9c96dff9f264d5fbb Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Sun, 26 Jan 2025 16:14:38 +0100 Subject: [PATCH] pimp ps1 --- users/pbsds/home/profiles/bashrc.d/ps1.sh | 13 +++++++++++++ users/pbsds/home/profiles/shell.nix | 5 ----- 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 users/pbsds/home/profiles/bashrc.d/ps1.sh diff --git a/users/pbsds/home/profiles/bashrc.d/ps1.sh b/users/pbsds/home/profiles/bashrc.d/ps1.sh new file mode 100644 index 0000000..35d1a03 --- /dev/null +++ b/users/pbsds/home/profiles/bashrc.d/ps1.sh @@ -0,0 +1,13 @@ +ps1_parse_git_branch() { + local retcode=$? + git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' + return $retcode +} +ps1_retcode_color() { + local retcode=$? + [ $? -eq 0 ] \ + && echo -e '\e[32m' \ + || echo -e '\e[33m' + return $retcode +} +export PS1='\[\033[01;32m\]\u@\h\[\033[01;37m\] \[\033[01;34m\]\W\[\033[33m\]$(ps1_parse_git_branch)$(ps1_retcode_color)\$\[\033[00m\] ' diff --git a/users/pbsds/home/profiles/shell.nix b/users/pbsds/home/profiles/shell.nix index f5d3c38..cadff49 100644 --- a/users/pbsds/home/profiles/shell.nix +++ b/users/pbsds/home/profiles/shell.nix @@ -26,11 +26,6 @@ in programs.bash.initExtra = '' bind 'set completion-ignore-case on' - parse_git_branch() { - git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' - } - export PS1='\[\033[01;32m\]\u@\h\[\033[01;37m\] \[\033[01;34m\]\W\[\033[33m\]$(parse_git_branch)\[\033[01;32m\]\$\[\033[00m\] ' - # tldr if command -v tldr >/dev/null; then complete -F _command tldr