I am too lazy and I just want to paste a servername or IP into my terminal for connecting via SSH:
$ server Connecting via SSH to root@server
$ 192.168.1.10 Connecting via SSH to root@192.168.1.10
$ vaporup@192.168.1.10 Connecting via SSH to vaporup@192.168.1.10
command_not_found_handle() { if [[ "$1" == *"@"* ]]; then echo "Connecting via SSH to $1" ssh "$1" else echo "Connecting via SSH to root@$1" ssh "root@$1" fi }
For ZSH you just have to add an *r* to the function name
command_not_found_handler() { if [[ "$1" == *"@"* ]]; then echo "Connecting via SSH to $1" ssh "$1" else echo "Connecting via SSH to root@$1" ssh "root@$1" fi }
command_not_found_handle() { [[ "$1" == *"@"* ]] && ssh "$1" || ssh "root@$1"; }
command_not_found_handler() { [[ "$1" == *"@"* ]] && ssh "$1" || ssh "root@$1"; }