Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

\H in PS1 adds the hostname without the domain to the prompt

15 views
Skip to first unread message

Sascha Gaspar

unread,
Jun 12, 2013, 1:37:09 AM6/12/13
to bug-...@gnu.org
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: x86_64-pc-linux-gnu-gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H -I. -I./include -I. -I./include -I./lib
-DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
:/sbin:/bin' -DSTANDARD_UTILS_PATH='/bin:/usr/bin:/sbin:/usr/sbin'
-DSYS_BASHRC='/etc/bash/bashrc'
-DSYS_BASH_LOGOUT='/etc/bash/bash_logout'
-DNON_INTERACTIVE_LOGIN_SHELLS -DSSH_SOURCE_BASHRC -march=core2 -O2
-pipe
uname output: Linux alpha 3.8.13-gentoo #2 SMP PREEMPT Sat May 25
10:12:13 CEST 2013 x86_64 Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
GenuineIntel GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.2
Patch Level: 45
Release Status: release

Description:

The \H in PS1 adds the hostname without the domain to the prompt.
According to the man page \h outputs the hostname up to the first `.'
and \H outputs the the hostname. I think that should be the FQDN?

Repeat-By:
# hostname
myhostname
# hostname -f
myhostname.mydomainname
# export PS1="\H $PS1"
myhostname #

Greg Wooledge

unread,
Jun 12, 2013, 8:38:17 AM6/12/13
to Sascha Gaspar, bug-...@gnu.org
On Wed, Jun 12, 2013 at 07:37:09AM +0200, Sascha Gaspar wrote:
> The \H in PS1 adds the hostname without the domain to the prompt.
> According to the man page \h outputs the hostname up to the first `.'
> and \H outputs the the hostname. I think that should be the FQDN?

Well, the manual says "the hostname".

> Repeat-By:
> # hostname
> myhostname

Since your system's hostname is set to the short form, that's what \H
gives you.

If you wanted \H to give the long form, then you would have to set your
system's hostname to the long form.

0 new messages