Skip to content

Commit 0366c57

Browse files
added git branch to bash ps1 prompt
1 parent 946c975 commit 0366c57

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

debian/changelog

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
byobu (6.12) unreleased; urgency=medium
22

3-
* UNRELEASED
3+
* usr/share/byobu/profiles/bashrc:
4+
- added git branch to bash ps1 prompt
45

5-
-- Dustin Kirkland <[email protected]> Sat, 10 Feb 2024 11:24:14 -0600
6+
-- Dustin Kirkland <[email protected]> Sat, 17 Feb 2024 06:18:47 -0600
67

78
byobu (6.11-0ubuntu1) noble; urgency=medium
89

usr/share/byobu/profiles/bashrc

+6-5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ esac
2828
[ -d "$BYOBU_PREFIX" ] || BYOBU_PREFIX="/usr"
2929
[ -r "$BYOBU_PREFIX/lib/byobu/include/dirs" ] && . "$BYOBU_PREFIX/lib/byobu/include/dirs"
3030

31+
byobu_prompt_git() { git branch 2>/dev/null | sed -e "/^[^*]/d" -e "s/* \(.*\)/ (\1)/"; }
3132
byobu_prompt_status() { local e=$?; [ $e != 0 ] && echo -e " $e "; }
3233
byobu_prompt_symbol() { [ "$USER" = "root" ] && printf "%s" "#" || printf "%s" "\$"; }
3334
byobu_prompt_runtime() {
@@ -51,15 +52,15 @@ byobu_prompt_runtime() {
5152
[ "$hours" = "0" ] && hours= || hours="${hours}h "
5253
[ "$minutes" = "0" ] && minutes= || minutes="${minutes}m "
5354
str="${days}${hours}${minutes}${seconds}.${microseconds}s"
54-
printf "[%s]" "$str" 1>&2
55+
printf "[%s] " "$str" 1>&2
5556
}
5657
# Requires Bash 4.x
5758
export PS0='$(printf "%s" ${EPOCHREALTIME/./} >"$BYOBU_RUN_DIR/timer.$$")'
5859

5960
case "$BYOBU_DISTRO" in
6061
"Ubuntu")
6162
# Use Ubuntu colors (grey / orange / aubergine)
62-
export PS1="${debian_chroot:+($debian_chroot)}\[\e[38;5;202m\]\$(byobu_prompt_status)\[\e[00m\]\$(byobu_prompt_runtime) \[\e[38;5;245m\]\u\[\e[00m\]@\[\e[38;5;172m\]\h\[\e[00m\]:\[\e[38;5;5m\]\w\[\e[00m\]\$(byobu_prompt_symbol) "
63+
export PS1="${debian_chroot:+($debian_chroot)}\[\e[03;5;15;202m\]\$(byobu_prompt_status)\[\e[00m\]\$(byobu_prompt_runtime)\[\e[38;5;245m\]\u\[\e[00m\]@\[\e[38;5;172m\]\h\[\e[00m\]:\[\e[38;5;5m\]\w\[\e[00m\]\e[38;5;102m\]\$(byobu_prompt_git)\e[00m\]\$(byobu_prompt_symbol) "
6364
export GREP_COLORS="ms=01;38;5;202:mc=01;31:sl=:cx=:fn=01;38;5;132:ln=32:bn=32:se=00;38;5;242"
6465
export LESS_TERMCAP_mb=$(printf '\e[01;31m') # enter blinking mode – red
6566
export LESS_TERMCAP_md=$(printf '\e[01;38;5;180m') # enter double-bright mode – bold light orange
@@ -75,14 +76,14 @@ case "$BYOBU_DISTRO" in
7576
fi
7677
;;
7778
"Wolfi")
78-
# Use Wolfi colors (pink / purple / grey)
79+
# Use Wolfi colors (pink / purple / blue)
7980
# For reference: https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg
8081
# Convert hex to 256: https://gist.githubusercontent.com/MicahElliott/719710/raw/73d047f0a3ffc35f0655488547e7f24fa3f04ea6/colortrans.py
8182
# Use Wolfi colors (pink=170 / purple=98 / blue=63); flashing error code on previous command non-zero exit
82-
PS1="\[\e[03;5;15;54m\]\$(byobu_prompt_status)\[\e[00m\]\$(byobu_prompt_runtime) \[\e[38;5;170m\]\u\[\e[00m\]@\[\e[38;5;98m\]\h\[\e[00m\]:\[\e[38;5;63m\]\w\[\e[00m\]\$(byobu_prompt_symbol) "
83+
PS1="\[\e[03;5;15;54m\]\$(byobu_prompt_status)\[\e[00m\]\$(byobu_prompt_runtime)\[\e[38;5;170m\]\u\[\e[00m\]@\[\e[38;5;98m\]\h\[\e[00m\]:\[\e[38;5;63m\]\w\[\e[00m\]\e[38;5;45m\]\$(byobu_prompt_git)\e[00m\]\$(byobu_prompt_symbol) "
8384
;;
8485
*)
8586
# Use Googley colors (blue / red / yellow / blue / green / red )
86-
PS1="${debian_chroot:+($debian_chroot)}\[\e[31m\]\$(byobu_prompt_status)\[\e[38;5;69m\]\u\[\e[38;5;214m\]@\[\e[38;5;167m\]\h\[\e[38;5;214m\]:\[\e[38;5;71m\]\w\[\e[38;5;214m\]\$(byobu_prompt_symbol)\[\e[00m\] "
87+
PS1="${debian_chroot:+($debian_chroot)}\[\e[31m\]\$(byobu_prompt_status)\[\e[38;5;69m\]\u\[\e[38;5;214m\]@\[\e[38;5;167m\]\h\[\e[38;5;214m\]:\[\e[38;5;71m\]\w\[\e[38;5;214m\]\$(byobu_prompt_git)\$(byobu_prompt_symbol)\[\e[00m\] "
8788
;;
8889
esac

0 commit comments

Comments
 (0)