You are not logged in.
My ${PS1} is as following (installed ohmyzsh, theme gentoo)
`%(!.%B%F{red}.%B%F{green}%n@)%m %F{blue}%(!.%1~.%~) ${vcs_info_msg_0_}%F{blue}%(!.#.$)%k%b%f`When login (open gui terminal, tty, ssh, etc) the prompt correctly displays something like this:
liparadise@arch ~ $Problem is, after doing any "cd", the abbreviation "%~" fails to work, and the prompt becomes like the following:
liparadise@arch /home/liparadise $Interestingly, if I do "cd ~liparadise", then "%~" somehow works (?) again, and the prompt becomes
liparadise@arch ~liparadise $Unfortunately, "cd ~" don't change prompt style, i.e. remain fully expanded or remain the "~user_name" style.
Problem remains either change $PS1 to plain '%~' or change to other themes in ohmyzsh.
My WSL2 debian machine have exactly the same .zshrc and ohmyzsh config, but "%~" works as expected, i.e. always abbreviating the ${HOME} portion of path to "~". Both machines are using latest version of ohmyzsh.
# pacman -Q --info zsh # arch machine on which ps1 seems problematic
Version : 5.8-1
# apt-show-versions zsh # WSL2 debian machine
zsh:amd64/bullseye 5.8-6+b2 uptodateLast edited by LIParadise (2021-12-01 08:10:09)
Offline
...installed ohmyzsh
That's most likely your problem. It's well known to break systems and there's nothing it does that can't be achieved by writing your own configs.
Offline
LIParadise wrote:...installed ohmyzsh
That's most likely your problem. It's well known to break systems and there's nothing it does that can't be achieved by writing your own configs.
Valid point, so I tried disabling zshrc and hence ohmyzsh and all zsh plugins (probably should do it in the first place) just now, and the problem persists, even with $PS1 being simply "%~'.
Last edited by LIParadise (2021-11-30 23:24:52)
Offline
"~liparadise" isn't "~"
Does something maybe unset $HOME ?
Edit: or your $UID?
Edit #2:
after doing any "cd"
It *is* "cd", not anything that triggers a new prompt?
type cd- do the contents of "/home/liparadise" change?
Last edited by seth (2021-12-01 05:37:23)
Offline
"~liparadise" isn't "~"
Does something maybe unset $HOME ?Edit: or your $UID?
Edit #2:after doing any "cd"
It *is* "cd", not anything that triggers a new prompt?
type cd- do the contents of "/home/liparadise" change?
Pardon but I don't really understand you.
Just to be clear:
I now only have "extra/zsh" installed; ohmyzsh is previously installed via git clone and setting its location in my zshrc, however ohmyzsh should not matter now since I removed zshrc from my home directory ("/home/liparadise/.zshrc")
Here's an experiment around $UID and $HOME (ssh), but again since unfortunately I don't quite get what you mean, so this might not be what you want:
Last login: Wed Dec 1 14:34:12 2021 from 140.112.238.126
arch% export PS1='%~: '
~: echo ${HOME} ${UID}
/home/liparadise/ 1000
~: cd
/home/liparadise: cd ~liparadise
~liparadise: cd
~liparadise: cd /home/liparadise
~liparadise: echo ${HOME} ${UID}
/home/liparadise/ 1000
~liparadise: type cd
cd is a shell builtinAnother experiment:
Last login: Wed Dec 1 14:34:21 2021 from 140.112.238.98
arch% export PS1='%~: '
~: unset HOME
/home/liparadise/: cd ~liparadise
~liparadise: cd /home/liparadise
~liparadise: cd ~
~liparadise:Offline
Update:
Now I have an opportunity to access another arch box, and I discover that I can't reproduce the bug mentioned. Since they use exactly the same "extra/zsh" package version, it's probably indeed some config wrong on my original machine.
I'll just mark the title solved for now, since it should just be that some of my config is messed up, rather than there be problem in "extra/zsh" in arch repo. I'll update my solution when I figure out why it behaves weird.
Offline
It's not technically "solved" - the idea behind my first questions was that the comparism between the $HOME for $UID and the $PWD fails.
If you'd "useradd -m dummy" and then "cd ~dummy" you'd end up in /home/dummy and zsh shows "~dummy"
id
stat ~
realpath ~
grep liparadise /etc/passwd # despite the name this won't expose your passwordOffline
It's not technically "solved" - the idea behind my first questions was that the comparism between the $HOME for $UID and the $PWD fails.
If you'd "useradd -m dummy" and then "cd ~dummy" you'd end up in /home/dummy and zsh shows "~dummy"id stat ~ realpath ~ grep liparadise /etc/passwd # despite the name this won't expose your password
Thanks for the hints, now problem is indeed solved!
Turns out my /etc/passwd is faulty somehow (possibly because a typo when I created a user for myself), the home directory part is "/home/liparadise/", causing it to mismatch $PWD, which doesn't have trailing "/", e.g. for my home directory $PWD shows "/home/liparadise". This can be seen even without peeking /etc/passwd via echo $HOME: on the faulty machine it's "/home/liparadise/" and on correctly configured machine it's "/home/liparadise", without the trailing "/".
I just blatantly directly edited "/etc/passwd", and now zsh behaves as expected. (I guess a safer way should be log out all my sessions and then do "usermod -d /home/liparadise liparadise" instead of recklessly manually modifying the file)
Thanks again since I've been pulling my hairs out for hours because all the zsh related config were basically the same across the board, never thought that the fault is due to faulty $HOME and that to solve the problem I should look into how $HOME is set in the first place.
Offline