Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hostname issue in bash #703

Open
Ergus opened this issue Mar 2, 2024 · 3 comments
Open

Hostname issue in bash #703

Ergus opened this issue Mar 2, 2024 · 3 comments

Comments

@Ergus
Copy link

Ergus commented Mar 2, 2024

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)

@Sbozzolo
Copy link
Collaborator

Sbozzolo commented Mar 5, 2024

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.

@Ergus
Copy link
Author

Ergus commented Mar 5, 2024

Also a nice solution!

@Sbozzolo
Copy link
Collaborator

Sbozzolo commented Mar 7, 2024

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

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants