I am trying to create a simple alias for SSH-ing to a host, like the below:
alias wpessh='ssh $1@$1.ssh.wpengine.net'
I also tried using a function as suggested by other answers here:
function wpessh { ssh "$1"@"$1".ssh.wpengine.net; }
export -f wpessh
But neither has worked.
Input
wpessh mysite
Expected Output (expected command to be run)
ssh mysite@mysite.ssh.wpengine.net
function wpessh { echo ssh "$1"@"$1".ssh.wpengine.net; }
– Sparhawk Oct 29 '18 at 09:44usage:[....]
– wickywills Oct 29 '18 at 09:59$1
contents when issuing the alias? What's the resulting command (tryset -x
)? Why the upper caseSSH
in the error msgs? – RudiC Oct 29 '18 at 10:02$@
instead of$1
? – BlackCrystal Oct 29 '18 at 10:11function foo { echo $1 $1 ; }
, thenfoo bar
? (Also, again, which shell are you using?) – Sparhawk Oct 29 '18 at 10:12echo $0
. (And the other suggestion I made.) – Sparhawk Oct 29 '18 at 10:21foo bar
function works for me. Also,echo $0
returns-bash
. Still can't see why my SSH function doesn't work though. – wickywills Oct 29 '18 at 10:26function wpessh { echo ssh "$1"@"$1".ssh.wpengine.net; }
in my OSX Shell both in bash and zsh and it's working fine. – BarathVutukuri Oct 29 '18 at 10:57ssh
command (a shorter version of what I receive when runningman ssh
). I.e. it doesn't actually run the SSH, but if I run the command myself, outside of the function, and replacing the$1
's with my domain, then it works fine. – wickywills Oct 29 '18 at 12:16ssh
is already an alias on your machine; what doesalias ssh
say? – Jan 13 '19 at 21:19-bash: alias: ssh: not found
, so nope, not an alias. – wickywills Jan 14 '19 at 07:14