You are not logged in.

#1 2021-09-27 02:00:44

cassii2
Member
Registered: 2021-09-27
Posts: 14

Bash/Zsh shows full directory instead of tilde after cd

After I cd into any directory, then go back to the home directory (even if I "cd ." or just "cd" from the home directory), the prompt shows the entire /home/user directory instead of the normal tilde ~.
This normally wouldn't be too much of an annoyance, but I mostly use zsh and p9k with the git plugin, and I have a .git directory in my home folder. It's pretty annoying to see the git status of my home directory all the time, usually it would automatically hide the git status in a ~ directory, but I think this problem is stopping that from working so I do see my git status in my home directory.
Any tips on how to fix this?

Offline

#2 2021-09-27 06:51:50

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,255

Re: Bash/Zsh shows full directory instead of tilde after cd

echo $PS1
echo $HOME

Either your prompt is using a bad pattern or your $HOME isn't set (properly) - w/ the additional git situation (though I can't say whether your assumption is correct) it's be more likely that your $HOME is off.

Online

#3 2021-09-27 15:47:04

cassii2
Member
Registered: 2021-09-27
Posts: 14

Re: Bash/Zsh shows full directory instead of tilde after cd

seth wrote:
echo $PS1
echo $HOME

Either your prompt is using a bad pattern or your $HOME isn't set (properly) - w/ the additional git situation (though I can't say whether your assumption is correct) it's be more likely that your $HOME is off.

$HOME gives me

/home/cassie/

and $PS1 is

[\u@\h \W]\$

for bash

Offline

#4 2021-09-27 15:51:56

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,255

Re: Bash/Zsh shows full directory instead of tilde after cd

Nope, that's very unfancy hmm

echo $PROMPT_DIRTRIM

?

Online

#5 2021-09-27 16:27:03

cassii2
Member
Registered: 2021-09-27
Posts: 14

Re: Bash/Zsh shows full directory instead of tilde after cd

echo $PROMPT_DIRTRIM

doesn't return anything at all actually

Offline

#6 2021-09-27 16:39:17

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,255

Re: Bash/Zsh shows full directory instead of tilde after cd

Good (default) and bad (we still don't know why it's not trimmed an I'm running out of ideas…)

Baseline:

env -i bash --norc --noprofile
export HOME=/home/cassie
export PS1='[\u@\h \W]\$ '

Online

#7 2021-09-27 16:42:24

cassii2
Member
Registered: 2021-09-27
Posts: 14

Re: Bash/Zsh shows full directory instead of tilde after cd

Oh, that actually works. CD'ing into the home directory shows I'm in ~ instead of /home/cassie, like it's supposed to

Offline

#8 2021-09-27 16:44:03

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,255

Re: Bash/Zsh shows full directory instead of tilde after cd

bash --norc --noprofile
export HOME=/home/cassie
export PS1='[\u@\h \W]\$ '

If that still works try
"bash --norc" and "bash --noprofile"

If not, "printenv"

Online

#9 2021-09-27 16:47:15

Ferdinand
Member
From: Norway
Registered: 2020-01-02
Posts: 338

Re: Bash/Zsh shows full directory instead of tilde after cd

My $PROMPT_DIRTRIM isn't set either - but your prompt works fine with me.
You haven't by any chance set an alias on cd that messes with your prompt?
Edit: Sorry too slow :-p

Last edited by Ferdinand (2021-09-27 16:49:46)

Offline

#10 2021-09-27 16:58:43

cassii2
Member
Registered: 2021-09-27
Posts: 14

Re: Bash/Zsh shows full directory instead of tilde after cd

"bash --norc" works correctly but "bash --noprofile" still has the same problem

Offline

#11 2021-09-27 17:00:28

cassii2
Member
Registered: 2021-09-27
Posts: 14

Re: Bash/Zsh shows full directory instead of tilde after cd

my entire .bashrc is empty too by the way, nothing in it at all.  Just

 #!/usr/bin/env bash

and "type cd" says it's a shell builtin, nothing about alias

Last edited by cassii2 (2021-09-27 17:01:43)

Offline

#12 2021-09-27 17:16:11

Ferdinand
Member
From: Norway
Registered: 2020-01-02
Posts: 338

Re: Bash/Zsh shows full directory instead of tilde after cd

Um.. I don't think you should have a shebang in .bashrc - it's not a script, it's a configuration file. It shouldn't be executable either.

Offline

#13 2021-09-27 17:22:48

cassii2
Member
Registered: 2021-09-27
Posts: 14

Re: Bash/Zsh shows full directory instead of tilde after cd

Huh, that makes sense actually, good point. It's not executable so I'm not sure how that got there, but I removed it. Nothing changed with my problem after clearing that file completely

Offline

#14 2021-09-27 19:06:02

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,255

Re: Bash/Zsh shows full directory instead of tilde after cd

What about

bash --rcfile /dev/null

Do you use a powerline theme on bash as well? How? Is there anything like oh-my-zsh/oh-my-bash involoved?

Online

#15 2021-09-27 19:18:21

cassii2
Member
Registered: 2021-09-27
Posts: 14

Re: Bash/Zsh shows full directory instead of tilde after cd

bash --rcfile /dev/null

still has the problem, and I do have oh-my-zsh installed, but this problem happens in both bash and zsh

Offline

#16 2021-09-27 19:22:19

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,255

Re: Bash/Zsh shows full directory instead of tilde after cd

Are you starting bash from (ultimately) within a zsh?

Do you have the problem for

env -i bash --norc
export HOME=/home/cassie
export PS1='[\u@\h \W]\$ 

Do you get the problem with
1. a fresh test user account
2. removing OMZ from your zshrc and a re-login?

Online

#17 2021-09-27 20:00:33

cassii2
Member
Registered: 2021-09-27
Posts: 14

Re: Bash/Zsh shows full directory instead of tilde after cd

Moving my .oh-my-zsh directory and .zshrc so that zsh starts with nothing, and going into bash from there, still has the problem. Using the "env -i bash --norc" does solve the problem.
A fresh user account also doesn't have this issue.

Offline

#18 2021-09-27 20:21:08

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,255

Re: Bash/Zsh shows full directory instead of tilde after cd

Try

env -i bash
export HOME=/home/cassie
export PS1='[\u@\h \W]\$ '

and post the output of "printenv" for the parenting shell, please.

Online

#19 2021-09-27 20:46:08

cassii2
Member
Registered: 2021-09-27
Posts: 14

Re: Bash/Zsh shows full directory instead of tilde after cd

The "env -i bash" also fixed the problem.
Output for printenv from that "env -i bash":

[cassie@cassie-laptop ~]$ printenv
PWD=/home/cassie
HOME=/home/cassie
SHLVL=1
PS1=[\u@\h \W]\$
OLDPWD=/home
_=/usr/bin/printenv

And the parent ZSH shell:

ALACRITTY_LOG=/tmp/Alacritty-160897.log
CLUTTER_BACKEND=wayland
COLORTERM=truecolor
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
DISPLAY=:0
ECORE_EVAS_ENGINE=wayland-egl
ELM_ENGINE=wayland_egl
GREETD_SOCK=/run/greetd-4674.sock
HOME=/home/cassie/
I3SOCK=/run/user/1000/sway-ipc.1000.153950.sock
LANG=en_US.UTF-8
LOGNAME=cassie
MAIL=/var/spool/mail/cassie
MOTD_SHOWN=pam
MOZ_ENABLE_WAYLAND=1
NO_AT_BRIDGE=1
PATH=/home/cassie/.local/bin:/home/cassie/.emacs.d/bin:/home/cassie/coding/dev-pebble/pebble-sdk-4.5-linux64/bin:/home/cassie/jdk1.8.0_301/bin:/home/cassie/scripts:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
PWD=/home/cassie/
QT_QPA_PLATFORM=wayland-egl
SDL_VIDEODRIVER=wayland
SHELL=/bin/zsh
SHLVL=2
SWAYSOCK=/run/user/1000/sway-ipc.1000.153950.sock
TERM=xterm-256color
USER=cassie
WAYLAND_DISPLAY=wayland-1
XCURSOR_SIZE=24
XDG_CONFIG_HOME=/home/cassie//.config
XDG_CURRENT_DESKTOP=sway
XDG_RUNTIME_DIR=/run/user/1000
XDG_SEAT=seat0
XDG_SESSION_CLASS=user
XDG_SESSION_DESKTOP=sway
XDG_SESSION_ID=10
XDG_SESSION_TYPE=wayland
XDG_VTNR=1
_=/usr/bin/printenv
_JAVA_AWT_WM_NONREPARENTING=1
OLDPWD=/home/cassie/
P9K_TTY=old
_P9K_TTY=/dev/pts/3
ZSH=/home/cassie/.oh-my-zsh
PAGER=less
LESS=-R
LSCOLORS=Gxfxcxdxbxegedabagacad
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
P9K_SSH=0
EDITOR=/home/cassie/scripts/et
RUST_SRC_PATH=/home/cassie/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src

Offline

#20 2021-09-27 20:53:32

cassii2
Member
Registered: 2021-09-27
Posts: 14

Re: Bash/Zsh shows full directory instead of tilde after cd

Oh! Just fixed it - the problem was that my $HOME was /home/cassie/ instead of /home/cassie. That one extra "/" messed it up.
Looks like my $HOME was set to /home/cassie/ when i first set up the user on my system, I gave the account a home directory with a "/" at the end and using "usermod -d /home/cassie cassie" in the root account fixed that little problem. Thanks for your help, everyone!

Last edited by cassii2 (2021-09-27 21:22:45)

Offline

Board footer

Powered by FluxBB