Alternative: leave a line in the PS1=
prompt of your .bashrc
. Here's literally how I set up .bashrc
on every linux machine I have:
PS1='
serg@ubuntu [$(pwd)]
================================
$ '
As you see in my example above, username is hardcoded into the prompt. You can of course use escape sequences that bash or another shell (e.g. ksh) provides, but a little more neutral option would be to do use parameter substitution with commands like whoami
(report your username) and hostname
(obviously, reports hostname). For instance:
PS1='
$(whoami)@$(hostname):$(pwd)
$ '
For more fun stuff with the prompt, .bashrc
, and parameter expansions, check out my answers here:
How to check battery status using terminal?
How can I get my terminals / shells to have custom designs in it? and
How to show a running clock in terminal before the command prompt?