Created
February 12, 2014 12:33
-
-
Save christianbundy/8954786 to your computer and use it in GitHub Desktop.
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
# let's assume the command is: | |
# sshcd -v -q [email protected]:/path/to/file | |
# grabs the last argument of command, the target: "[email protected]:/path/to/file | |
t="${!#}" | |
# command to run, which I've broken down line by line | |
c=( | |
"ssh" | |
"-t" # force pseudo-tty allocation (http://www.openbsd.org/cgi-bin/man.cgi?query=ssh&sektion=1) | |
"${@:1:$(($#-1))}" # list each of the arguments other than the target ("-v -q") | |
"${t%:*}" # target before the last ":" | |
"cd ${t##*:}; \$SHELL -l" # target before the first ":", and start the shell | |
) | |
"${c[@]}" # run the command |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment