From 3d303f66fa61a7680105e8b47609b4e1abbf38d6 Mon Sep 17 00:00:00 2001 From: PulkoMandy Date: Tue, 20 Dec 2022 19:31:27 +0100 Subject: [PATCH] zsh: fix prompt configuration Create a default zshrc file that sets up the prompt to behave the same as the bash one set by Haiku. There was an attempt to patch the prompt in zprofile already (after sourcing /etc/profile), but the prompt is now too complex for the simple substitutions to work. Avoids the problem reported in https://dev.haiku-os.org/ticket/17652 --- app-shells/zsh/additional-files/zprofile | 1 - app-shells/zsh/additional-files/zshrc | 11 +++++++++++ app-shells/zsh/zsh-5.8.1.recipe | 9 ++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 app-shells/zsh/additional-files/zshrc diff --git a/app-shells/zsh/additional-files/zprofile b/app-shells/zsh/additional-files/zprofile index 98335caa7..886fad060 100644 --- a/app-shells/zsh/additional-files/zprofile +++ b/app-shells/zsh/additional-files/zprofile @@ -1,6 +1,5 @@ # Emulate ksh as a walkaround for ksh-syntax within /etc/profile emulate ksh -c 'source /etc/profile' -PS1="${PS1/'$PWD'/%~}" # Migration path for users who rely on the old behavior ( diff --git a/app-shells/zsh/additional-files/zshrc b/app-shells/zsh/additional-files/zshrc new file mode 100644 index 000000000..ce9cca2a8 --- /dev/null +++ b/app-shells/zsh/additional-files/zshrc @@ -0,0 +1,11 @@ +# Set PS1 similar to Haiku /etc/profile, but using zsh syntax +_ARCH=`getarch 2>/dev/null` +if [ "$_ARCH" = "`getarch -p 2>/dev/null`" ] ; then + PS1="%~" +else + PS1="[$_ARCH] %~" +fi +unset _ARCH + +export PS1="%(?.%F{green}.%F{red})$PS1%f> " + diff --git a/app-shells/zsh/zsh-5.8.1.recipe b/app-shells/zsh/zsh-5.8.1.recipe index d5ecae933..f9ac8b8ed 100644 --- a/app-shells/zsh/zsh-5.8.1.recipe +++ b/app-shells/zsh/zsh-5.8.1.recipe @@ -7,7 +7,7 @@ HOMEPAGE="https://www.zsh.org/" COPYRIGHT="1992-2020 The Zsh Development Group" LICENSE="ZSH GNU GPL v2" -REVISION="1" +REVISION="2" SOURCE_URI="https://downloads.sf.net/zsh/zsh-$portVersion.tar.xz" CHECKSUM_SHA256="b6973520bace600b4779200269b1e5d79e5f505ac4952058c11ad5bbf0dd9919" SOURCE_URI_2="https://downloads.sf.net/zsh/zsh-$portVersion-doc.tar.xz" @@ -16,6 +16,7 @@ PATCHES="zsh-$portVersion.patchset" ADDITIONAL_FILES=" zprofile zshenv + zshrc " ARCHITECTURES="all ?x86" @@ -26,7 +27,7 @@ GLOBAL_WRITABLE_FILES=" settings/zsh/zlogout settings/zsh/zprofile keep-old settings/zsh/zshenv keep-old - settings/zsh/zshrc + settings/zsh/zshrc keep-old " USER_SETTINGS_FILES=" settings/zsh directory @@ -117,12 +118,14 @@ INSTALL() install -d -m 755 "$settingsDir/zsh" - # Source /etc/profile on startup, which contains important settings + # Source /etc/profile on startup, which contains important settings. Set PS1 to behave + # similarly to what's set in /etc/profile, but using zsh compatible syntax # Keep dots in B_USER_SETTINGS_DIRECTORY, if the user hasn't got any # dots in their home directory install -m 644 \ "$portDir"/additional-files/zprofile \ "$portDir"/additional-files/zshenv \ + "$portDir"/additional-files/zshrc \ "$settingsDir"/zsh make install.html