You are not logged in.
The bash prompt has w and W to show the current directory in the prompt.
Unfortunately I have multiple folders with the same name but in different locationsfor different purposes..
example :
~/Documents/Games/MM7
~/Downloads/Games/MM7
~/pkgbuilds/llvm-minimal-git
~/git-repos/AUR/llvm-minimal-git
Showing the full path in the prompt is overkill and likely way to long but showing the path relative to $HOME for folders under $HOME would be very handy .
So instead of MM7 it should be Documents/Games/MM7 or Downloads/Games/MM7
Last edited by Lone_Wolf (2026-07-22 12:05:31)
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
I did this by using a custom function
meow() {
case "$1" in
"$HOME")
printf '~'
;;
"$HOME"/*)
printf '~/%s' "${1#$HOME/}"
;;
*)
printf '%s' "$1"
;;
esac
}and used `PS1='$(meow "$PWD") \$ ' ` in prompt
...
Edit
or
export PROMPT_DIRTRIM=3
PS1='\u@\h \w \$ 'like if your goal is to always show the full path under your home directory (for ex. always showing ~/Documents/Games/MM7) then PROMPT_DIRTRIM is not the right tool...
Edit2:
changed the function to accept the path as an argument instead of relying on the global $PWD variable
Last edited by 5hridhyan (2026-07-18 12:40:48)
Offline
Yup, PROMPT_DIRTRIM=3 comes close .
Will test that and the function you posted in the next days to verify which works best for me.
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
Have you ever tried just the basic https://archlinux.org/packages/extra/an … sh-config/ ?
https://archlinux.org/packages/extra/an … hlighting/ (you'll have to source that) is also fun.
(the grml config auto-elides the prompt to 40 chars max)
Online
Nope, only times I used zsh was during installing from the iso (atleast I think the iso uses grml zsh) .
Sofar the whole path from ~ to folder is TMI as ~/pkgbuilds/llvm-minimal-git/src/llvm-project starts 4 levels deep and has atleast 4 nested levels itself .
PROMPT_DIRTRIM=2 is not enough info, 3 is usable.
[panoramix@mjoelnir ~/.../oolite/KicheEmergencyShields/Scripts] (master)$ The total size of that is ~ 70 chars, how would grml handle that ?
How does grml handle longer prompts then 40 chars ?
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
It left-elides the path, not the rest of the promt - or rather the token '%40<..<%~%<< ' does that in zsh - the grml config provides an abstraction layer to the config.
You can run "prompt -h grml" to get an oversight how to customize that.
It's a bit like a less annoying OMZ … and maybe a way to covert you to use ze zuperior zhell ![]()
Online
Looked at zsh with grml-zsh-config . The completion is better then that used in bash.
Things I'd have to change :
Seeing (git)-(master) is too much info as I don't use other VCS then git
The truncation of longer paths is annoying for me as I very much prefer path display stopping at a / .
ls sort order is case sensitive which I hate for directory output .
(under bash ls displays clang.ini before CMake.txt)
The question comes down to : Is the extra power the zsh shell gives worth the effort needed to tweak it to my wishes ?
For bash I have done very little tweaking.
I will keep zsh+grml installed for now.
As for the topic of this thread :
PROMPT_DIRTRIM=3 works well, marking as [Solved].
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
zstyle ':vcs_info:*' actionformats "%F{red}%b%f:%F{green}%a%f " "zsh: %r"
zstyle ':vcs_info:*' formats "%F{red}%b%f " "zsh: %r"
# limit prompt to trailing three segments
zstyle ':prompt:grml:*:items:path' token '%3~'ls sorts according to LC_COLLATE which is likely set to some C (or unset) in zsh but set to some utf8 locale bash?
Online
LC_COLLATE is unset on my system.
$ alias | grep ls=
ls='command ls --color=auto -v'Looks like that comes from /etc/zsh/.zshrc which is owned by grml-zsh-config.
It's the -v that caused it, apparently it does affect more then number sort.
Copying alias ls='ls --color=auto --group-directories-first' for my ~/.bashrc solved the issue
grml-zsh-config comes with a lot of aliases that I don't need (my ~/.bashrc only has 4 aliases)
I just noticed zsh (probably ZLE?) has different ideas then me about what the home-key on keyboard should do.
Not removing it yet, but my feeling sofar is that zsh/grml authors and I have different ideas about how things should work.
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
grml-zsh-config comes with a lot of
tbc, it's a very generic config that actually carries a lot of "cruft" (including a lot of debian specific stuff, obviously) - it's more to showcase the environment, zsh's abilities do neither start nor end there.
I just noticed zsh (probably ZLE?) has different ideas then me about what the home-key on keyboard should do.
Specifically? (Jumps to the start of the line for me)
Online
Double checked, both home and end produce a ~ symbol .
With numlock disabled the home and end keys on the numeric block do the same .
Even the delete key gives ~ now.
I've removed grml-zsh-config, no difference .
My keyboard is a logitech wired K120 without any special keys. It's about the simplest you can find.
X complains about a few things related to keyboard but has done so since I bought it.
The XKEYBOARD keymap compiler (xkbcomp) reports:
> Warning: Multiple symbols for level 1/group 1 on key <FK23>
> Using F23, ignoring XF86TouchpadOff
> Warning: Symbol map for key <FK23> redefined
> Using last definition for conflicting fields
> Warning: Symbol map for key <FK24> redefined
> Using last definition for conflicting fields
> Warning: Could not resolve keysym XF86ElectronicPrivacyScreenOn
> Warning: Could not resolve keysym XF86ElectronicPrivacyScreenOff
> Warning: Could not resolve keysym XF86ActionOnSelection
> Warning: Could not resolve keysym XF86ContextualInsert
> Warning: Could not resolve keysym XF86ContextualQuery
Errors from xkbcomp are not fatal to the X serverI'll consider creating a test user with zsh as default shell to give a chance. Maybe next week when temps get above 30 again and I need to do something at 0300 when temp outside is below temp inside.
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
IOW the home key does nothing (you get ESC~)
bindkey -e # "emacs" navigation in zle, you probably want that
bindkey "\e[1~" beginning-of-line
bindkey "\e[1;5D" backward-word
bindkey "\e[4~" end-of-line
bindkey "\e[1;5C" forward-word
bindkey "\e[3~" delete-char
r-delregion() {
if ((REGION_ACTIVE)) then
zle kill-region
else
local widget_name=$1
shift
zle $widget_name -- $@
fi
}
r-deselect() {
((REGION_ACTIVE = 0))
local widget_name=$1
shift
zle $widget_name -- $@
}
r-select() {
((REGION_ACTIVE)) || zle set-mark-command
local widget_name=$1
shift
zle $widget_name -- $@
}
r-copy() {
if ((REGION_ACTIVE)); then
zle copy-region-as-kill
print -rn -- $CUTBUFFER | xsel -b -i
else
# Nothing is selected, so default to the interrupt command
zle send-break
fi
}
for key seq mode widget (
sleft '\e[1;2D' select backward-char
sright '\e[1;2C' select forward-char
send '\E[1;2F' select end-of-line
shome '\E[1;2H' select beginning-of-line
csleft '\E[1;6D' select backward-word
csright '\E[1;6C' select forward-word
del '\E[3~' delregion delete-char
bs '^?' delregion backward-delete-char
sins '^[[2;5~' copy ""
) {
eval "key-$key() {
r-$mode $widget \$@
}"
zle -N key-$key
bindkey $seq key-$key
}nb. that "r-copy" utilizes xsel to the things into the X11 clipboard and adjust that accordingly
Online
That means I have to port readline /etc/inputrc into zshrc to get zle to support the same functionality ?
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
https://wiki.archlinux.org/title/Zsh#Key_bindings
The upside is that you're not constrained by readline either
(I really expected the grml config to set this up already)
Online