emacs-libvterm icon indicating copy to clipboard operation
emacs-libvterm copied to clipboard

Hostname issue in bash

Open Ergus opened this issue 5 months ago • 3 comments

Hi:

The hostname command is not part of bash by default. It seems like some distros deliver the variable $HOSTNAME instead. For those distros (like mine Arch Linux) it may be better to change

vterm_prompt_end(){
    vterm_printf "51;A$(whoami)@${HOSTNAME}:$(pwd)"
}

Or a more elaborated alternative that attempts to use the right version like:

[[ -n $HOSTNAMEE ]] && echo $HOSTNAME || (command -v hostname > /dev/null && hostname)

or similar (I am sure it may be a much better alternative)

Ergus avatar Mar 02 '24 14:03 Ergus

Interesting, I always assumed that hostname was available everywhere. It is not a bash-builtin, but a binary. I guess we could change it to uname -n, which should be POSIX.

I personally find $HOSTNAME not very robust. It is a variable and as such users/admins could change it.

Sbozzolo avatar Mar 05 '24 16:03 Sbozzolo

Also a nice solution!

Ergus avatar Mar 05 '24 16:03 Ergus

If you open a PR, I'll merge it :)

Thanks in advance!

Sbozzolo avatar Mar 07 '24 16:03 Sbozzolo