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
This commit is contained in:
PulkoMandy
2022-12-20 19:31:27 +01:00
parent b70c7c4e20
commit 3d303f66fa
3 changed files with 17 additions and 4 deletions

View File

@@ -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
(

View File

@@ -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> "

View File

@@ -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