Last active
May 13, 2022 16:54
-
-
Save cvonkleist/658b6f98346bf51769e96049f84bb45d to your computer and use it in GitHub Desktop.
Get IP address of hostname in SSH config, with ZSH completion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# show ip address for ssh host, with zsh completion for hostname | |
_sship () { ssh -G $1 | awk '/^hostname/ {print $2}' } | |
compdef _sship=ssh | |
# Usage | |
# ===== | |
# Add the above two lines to the bottom of your ~/.zshrc file. | |
# | |
# Use it like this on the commandline: | |
# | |
# _sship somebox1 | |
# 11.22.33.44 # <= this is what it will print | |
# | |
# This is what your ~/.ssh/config might look like: | |
# | |
# Host somebox1 | |
# HostName 11.22.33.44 | |
# Host otherbox22 | |
# LocalForward 1234 localhost:4567 | |
# HostName 22.33.44.55 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment