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

Add Fallbacks for Setting WEZTERM_HOST in Non-Systemd and Minimal Environments #6370

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions assets/shell-integration/wezterm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -510,15 +510,20 @@ __wezterm_user_vars_precmd() {

# You may set WEZTERM_HOSTNAME to a name you want to use instead
# of calling out to the hostname executable on every prompt print.
if [[ -z "${WEZTERM_HOSTNAME}" ]] ; then
if hash hostname 2>/dev/null ; then
__wezterm_set_user_var "WEZTERM_HOST" "$(hostname)"
elif hash hostnamectl 2>/dev/null ; then
__wezterm_set_user_var "WEZTERM_HOST" "$(hostnamectl hostname)"
fi
if [[ -z "${WEZTERM_HOSTNAME}" ]]; then
if [[ -r /proc/sys/kernel/hostname ]]; then
__wezterm_set_user_var "WEZTERM_HOST" "$(cat /proc/sys/kernel/hostname)"
elif hash hostname 2>/dev/null; then
__wezterm_set_user_var "WEZTERM_HOST" "$(hostname)"
elif hash hostnamectl 2>/dev/null; then
__wezterm_set_user_var "WEZTERM_HOST" "$(hostnamectl hostname)"
else
__wezterm_set_user_var "WEZTERM_HOST" "${WEZTERM_HOSTNAME}"
__wezterm_set_user_var "WEZTERM_HOST" "unknown"
fi
else
__wezterm_set_user_var "WEZTERM_HOST" "${WEZTERM_HOSTNAME}"
fi

}

__wezterm_user_vars_preexec() {
Expand Down