Skip to content

Use POSIX-compliant uname instead of hostname #14

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
12 changes: 4 additions & 8 deletions shell_integration/bash
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ function iterm2_end_osc {
function iterm2_print_state_data() {
local _iterm2_hostname="${iterm2_hostname}"
if [ -z "${iterm2_hostname:-}" ]; then
_iterm2_hostname=$(hostname -f 2>/dev/null)
_iterm2_hostname=$(uname -n 2>/dev/null)
fi
iterm2_begin_osc
printf "1337;RemoteHost=%s@%s" "$USER" "$_iterm2_hostname"
Expand Down Expand Up @@ -516,15 +516,11 @@ function iterm2_print_version_number() {
}


# If hostname -f is slow on your system, set iterm2_hostname before sourcing this script.
# On macOS we run `hostname -f` every time because it is fast.
# If uname -n is slow on your system, set iterm2_hostname before sourcing this script.
# On macOS we run `uname -n` every time because it is fast.
if [ -z "${iterm2_hostname:-}" ]; then
if [ "$(uname)" != "Darwin" ]; then
iterm2_hostname=$(hostname -f 2>/dev/null)
# some flavors of BSD (i.e. NetBSD and OpenBSD) don't have the -f option
if [ $? -ne 0 ]; then
iterm2_hostname=$(hostname)
fi
iterm2_hostname=$(uname -n 2>/dev/null)
fi
fi

Expand Down
12 changes: 4 additions & 8 deletions shell_integration/fish
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ if begin; status --is-interactive; and not functions -q -- iterm2_status; and [

function iterm2_write_remotehost_currentdir_uservars
if not set -q -g iterm2_hostname
printf "\033]1337;RemoteHost=%s@%s\007\033]1337;CurrentDir=%s\007" $USER (hostname -f 2>/dev/null) $PWD
printf "\033]1337;RemoteHost=%s@%s\007\033]1337;CurrentDir=%s\007" $USER (uname -n 2>/dev/null) $PWD
else
printf "\033]1337;RemoteHost=%s@%s\007\033]1337;CurrentDir=%s\007" $USER $iterm2_hostname $PWD
end
Expand Down Expand Up @@ -108,16 +108,12 @@ if begin; status --is-interactive; and not functions -q -- iterm2_status; and [
end
end

# If hostname -f is slow for you, set iterm2_hostname before sourcing this script
# If uname -n is slow for you, set iterm2_hostname before sourcing this script
if not set -q -g iterm2_hostname
# hostname -f is fast on macOS so don't cache it. This lets us get an updated version when
# uname -n is fast on macOS so don't cache it. This lets us get an updated version when
# it changes, such as if you attach to a VPN.
if [ (uname) != Darwin ]
set -g iterm2_hostname (hostname -f 2>/dev/null)
# some flavors of BSD (i.e. NetBSD and OpenBSD) don't have the -f option
if test $status -ne 0
set -g iterm2_hostname (hostname)
end
set -g iterm2_hostname (uname -n 2>/dev/null)
end
end

Expand Down
2 changes: 1 addition & 1 deletion shell_integration/source/bash.0
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


# -- BEGIN ITERM2 CUSTOMIZATIONS --
if [[ "$ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX""$TERM" != screen && "$ITERM_SHELL_INTEGRATION_INSTALLED" = "" && "$-" == *i* && "$TERM" != linux && "$TERM" != dumb ]]; then
if [[ "$ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX""$TERM" != screen && "$ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX""$TERM" != tmux-256color && "$ITERM_SHELL_INTEGRATION_INSTALLED" = "" && "$-" == *i* && "$TERM" != linux && "$TERM" != dumb ]]; then

if shopt extdebug | grep on > /dev/null; then
echo "iTerm2 Shell Integration not installed."
Expand Down
10 changes: 5 additions & 5 deletions shell_integration/source/bash.1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function iterm2_end_osc {
function iterm2_print_state_data() {
local _iterm2_hostname="${iterm2_hostname}"
if [ -z "${iterm2_hostname:-}" ]; then
_iterm2_hostname=$(hostname -f 2>/dev/null)
_iterm2_hostname=$(uname -n 2>/dev/null)
fi
iterm2_begin_osc
printf "1337;RemoteHost=%s@%s" "$USER" "$_iterm2_hostname"
Expand Down Expand Up @@ -74,16 +74,16 @@ function iterm2_prompt_suffix() {

function iterm2_print_version_number() {
iterm2_begin_osc
printf "1337;ShellIntegrationVersion=17;shell=bash"
printf "1337;ShellIntegrationVersion=18;shell=bash"
iterm2_end_osc
}


# If hostname -f is slow on your system, set iterm2_hostname before sourcing this script.
# On macOS we run `hostname -f` every time because it is fast.
# If uname -n is slow on your system, set iterm2_hostname before sourcing this script.
# On macOS we run `uname -n` every time because it is fast.
if [ -z "${iterm2_hostname:-}" ]; then
if [ "$(uname)" != "Darwin" ]; then
iterm2_hostname=$(hostname -f 2>/dev/null)
iterm2_hostname=$(uname -n 2>/dev/null)
# some flavors of BSD (i.e. NetBSD and OpenBSD) don't have the -f option
if [ $? -ne 0 ]; then
iterm2_hostname=$(hostname)
Expand Down
10 changes: 3 additions & 7 deletions shell_integration/tcsh
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,16 @@ if ( ! ($?iterm2_shell_integration_installed)) then
alias _iterm2_end_prompt 'printf "\007"'

# Define aliases for printing the current hostname
# If hostname -f is slow to run on your system, set iterm2_hostname before sourcing this script.
# If uname -n is slow to run on your system, set iterm2_hostname before sourcing this script.
if ( ! ($?iterm2_hostname)) then
# hostname is fast on macOS so don't cache it. This lets us have an up to date value if it
# changes because you connect to a VPN, for example.
if ( `uname` != Darwin ) then
set iterm2_hostname=`hostname -f |& cat || false`
# some flavors of BSD (i.e. NetBSD and OpenBSD) don't have the -f option
if ( $status != 0 ) then
set iterm2_hostname=`hostname`
endif
set iterm2_hostname=`uname -n |& cat || false`
endif
endif
if ( ! ($?iterm2_hostname)) then
alias _iterm2_print_remote_host 'printf "1337;RemoteHost=%s@%s" "$USER" `hostname -f`'
alias _iterm2_print_remote_host 'printf "1337;RemoteHost=%s@%s" "$USER" `uname -n`'
else
alias _iterm2_print_remote_host 'printf "1337;RemoteHost=%s@%s" "$USER" "$iterm2_hostname"'
endif
Expand Down
10 changes: 3 additions & 7 deletions shell_integration/zsh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ if [[ -o interactive ]]; then
iterm2_print_state_data() {
local _iterm2_hostname="${iterm2_hostname-}"
if [ -z "${iterm2_hostname:-}" ]; then
_iterm2_hostname=$(hostname -f 2>/dev/null)
_iterm2_hostname=$(uname -n 2>/dev/null)
fi
printf "\033]1337;RemoteHost=%s@%s\007" "$USER" "${_iterm2_hostname-}"
printf "\033]1337;CurrentDir=%s\007" "$PWD"
Expand Down Expand Up @@ -152,17 +152,13 @@ if [[ -o interactive ]]; then
iterm2_before_cmd_executes
}

# If hostname -f is slow on your system set iterm2_hostname prior to
# If uname -n is slow on your system set iterm2_hostname prior to
# sourcing this script. We know it is fast on macOS so we don't cache
# it. That lets us handle the hostname changing like when you attach
# to a VPN.
if [ -z "${iterm2_hostname-}" ]; then
if [ "$(uname)" != "Darwin" ]; then
iterm2_hostname=`hostname -f 2>/dev/null`
# Some flavors of BSD (i.e. NetBSD and OpenBSD) don't have the -f option.
if [ $? -ne 0 ]; then
iterm2_hostname=`hostname`
fi
iterm2_hostname=`uname -n 2>/dev/null`
fi
fi

Expand Down
Empty file modified utilities/it2ssh
100644 → 100755
Empty file.