emacs-libvterm
emacs-libvterm copied to clipboard
Hostname issue in bash
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)
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.
Also a nice solution!
If you open a PR, I'll merge it :)
Thanks in advance!