0

for example, instead of displaying user@hostname:/home/user in the prompt as per the example in the manpage, could one make mksh display user@hostname:~ ?

pernia
  • 3
  • 2

1 Answers1

1

Replace "\$PWD" from the manpage with '${PWD/#"$HOME"/\~}'. This will replace $HOME with ~ if it appears at the beginning of $PWD. eg:

PS1='${USER:=$(id -un)}'"@${HOSTNAME:=$(hostname -s)}:"'${PWD/#"$HOME"/\~} '
user
  • 161
  • 3
  • I changed mine to this: ```PS1='[${USER:=$(id -un)}'"@${HOSTNAME:=$(hostname)} \${PWD/#'$HOME'/\~}]$(if (( USER_ID )); then print \$; else print \#; fi) " ``` so it look like this ```[user@hostname ~]$ ``` thanks! – pernia Mar 05 '20 at 13:52
  • See also the default `PS1` shipped in `dot.mkshrc`, which does that *and* length-limits the PWD additionally. – mirabilos Mar 02 '22 at 19:01