Why the home directory is not ~ anymore in Debian 9

If none of the more specific forums is the right place to ask

Why the home directory is not ~ anymore in Debian 9

Postby zhiyizhi » 2017-06-26 01:54

In Debian 8, the tilde ~ denotes the home directory. But in 9, it seems that the home directory is just itself. So, how can I configure such that the home directory is denoted by ~, just as in Debian 8? Below is part of my ~/.bashrc file:
Code: Select all
if [ "$color_prompt" = yes ]; then
    #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    PS1="[\$(date +%m/%d/%Y),\t@\w]\$ "
else
    #PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    PS1="[\$(date +%m/%d/%Y),\t@\w]\$ "
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    #PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    PS1="[\$(date +%m/%d/%Y),\t@\W]\$ "
zhiyizhi
 
Posts: 25
Joined: 2008-09-07 07:45

Re: Why the home directory is not ~ anymore in Debian 9

Postby orythem27 » 2017-06-26 04:29

Please post the output of the following commands.
Code: Select all
/bin/ps u -p $$
echo $HOME
cd ~; pwd


zhiyizhi wrote:But in 9, it seems that the home directory is just itself.

Please supply an example.
User avatar
orythem27
 
Posts: 252
Joined: 2017-05-11 07:59
Location: P.R. China

Re: Why the home directory is not ~ anymore in Debian 9

Postby zhiyizhi » 2017-06-26 07:23

The output is below:

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
xxxyyy 9349 0.0 0.0 26996 3420 pts/5 Ss+ 16:10 0:00 bash
/home/lovelinux/
/home/lovelinux

Can you tell me what the function of these commands is?
zhiyizhi
 
Posts: 25
Joined: 2008-09-07 07:45

Re: Why the home directory is not ~ anymore in Debian 9

Postby orythem27 » 2017-06-26 07:36

zhiyizhi wrote:USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
xxxyyy 9349 0.0 0.0 26996 3420 pts/5 Ss+ 16:10 0:00 bash

So you are indeed using bash, not other shells, which means you should get tilde expansion on ~.
I assume that "xxxyyy" is the same string as "lovelinux", which is your actual username.

zhiyizhi wrote:/home/lovelinux/
/home/lovelinux

So when you execute `cd ~`, it indeed goes to your home folder. So the bash tilde expansion is working. Can you provide an example that makes you think "the home directory is not ~ anymore"?
User avatar
orythem27
 
Posts: 252
Joined: 2017-05-11 07:59
Location: P.R. China

Re: Why the home directory is not ~ anymore in Debian 9

Postby wertz » 2017-06-26 10:10

on KDE, ~ goes to home folder,, but on MATE and Xfce ~ just stays on the same directory(or somewhere else but not home)
wertz
 
Posts: 6
Joined: 2017-06-25 21:16

Re: Why the home directory is not ~ anymore in Debian 9

Postby zhiyizhi » 2017-06-26 13:09

In Debian 9, the appearance of Mate-terminal is like this:
Code: Select all
[06/26/2017,21:43:41@/home/lovelinux]$ cd Desktop/
[06/26/2017,21:43:49@/home/lovelinux/Desktop]$ cd /
[06/26/2017,21:43:53@/]$ pwd
/
[06/26/2017,21:43:55@/]$ cd ~/Desktop/
[06/26/2017,21:44:00@/home/lovelinux/Desktop]$

But I want it to be as this:
Code: Select all
20:45:02@~ $ pwd
/home/lovemint
20:45:06@~ $ cd Desktop/
20:45:09@~/Desktop $ ls
20:45:14@~/Desktop $ pwd
/home/lovemint/Desktop
20:45:15@~/Desktop $ cd /
20:45:37@/ $ pwd
/
20:45:37@/ $

That is to say, I want terminal not to replace the tilde to $HOME. How can I set ~/.bashrc in Debian 9, so that it is really what I want.
zhiyizhi
 
Posts: 25
Joined: 2008-09-07 07:45

Re: Why the home directory is not ~ anymore in Debian 9

Postby dasein » 2017-06-26 13:17

First you say:
zhiyizhi wrote:So, how can I configure such that the home directory is denoted by ~
But then you turn around and say:
zhiyizhi wrote:I want terminal not to replace the tilde to $HOME.
So, your two goals are mutually exclusive. It's not surprising that everyone's confused.

Good luck.
User avatar
dasein
 
Posts: 7775
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: Why the home directory is not ~ anymore in Debian 9

Postby orythem27 » 2017-06-26 14:22

zhiyizhi wrote:In Debian 9, the appearance of Mate-terminal is like this:
[06/26/2017,21:43:41@/home/lovelinux]$ cd Desktop/

But I want it to be as this:
20:45:02@~ $ pwd

That is to say, I want terminal not to replace the tilde to $HOME

Arghhh, it took me ~5 minutes to get your point. So you would like to see "~" instead of "/home/lovelinux" in your bash prompt, which should be the normal behaviour according to the documentation. Is this correct?

If this is the case, there are numerous possibilities that could cause the tilde abbreviation to fail in PS1. One of them is that you have a erratic HOME variable. A quick search reveals several cases:
http://gnu-bash.2382.n7.nabble.com/bug-Home-dir-in-PS1-not-abbreviated-to-tilde-td680.html
https://unix.stackexchange.com/questions/366643/parameters-in-bash-ps1-variable
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=859384
User avatar
orythem27
 
Posts: 252
Joined: 2017-05-11 07:59
Location: P.R. China

Re: Why the home directory is not ~ anymore in Debian 9

Postby dasein » 2017-06-26 14:31

orythem27 wrote:Arghhh, it took me ~5 minutes to get your point. So you would like to see "~" instead of "/home/lovelinux" in your bash prompt...

(1) Kudos to you, orythem27, for figuring it out at all.

(2) @OP -> All this drama and effort... for a bash prompt? Seriously? You need better hobbies.
User avatar
dasein
 
Posts: 7775
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: Why the home directory is not ~ anymore in Debian 9

Postby orythem27 » 2017-06-26 14:42

zhiyizhi wrote:The output is below:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
xxxyyy 9349 0.0 0.0 26996 3420 pts/5 Ss+ 16:10 0:00 bash
/home/lovelinux/
/home/lovelinux

According to the links above, the problem is that you have an extra trailing slash in your HOME variable, which could be wrongly set in /etc/passwd or bashrc.

dasein wrote:(1) Kudos to you, orythem27, for figuring it out at all.

Thanks. :) I guess OP has been giving the forum members a hard time by not emphasizing "PS1" or "prompt", but I totally overlooked that OP had already mentioned setting PS1 in the opening post. :roll:
User avatar
orythem27
 
Posts: 252
Joined: 2017-05-11 07:59
Location: P.R. China

Re: Why the home directory is not ~ anymore in Debian 9

Postby zhiyizhi » 2017-06-26 23:53

I have solved the problem, by using the method suggested in the thread https://unix.stackexchange.com/questions/366643/parameters-in-bash-ps1-variable. I have deleted the redundant slash after the Home directory in /etc/passwd. Of curiosity is that why there is not such a problem in Debian 8, while it is in Debian 9?
zhiyizhi
 
Posts: 25
Joined: 2008-09-07 07:45


Return to General Questions

Who is online

Users browsing this forum: No registered users and 6 guests

fashionable