shell@alias支持变量传递

问题

在 Linux 或 macOS 的 shell(如 Bash、Zsh)中使用 alias 时,不能直接为 alias 设置带参数的形式alias 是对命令的简单文本替换,不支持像函数那样接收参数。不过,你可以使用 shell 函数 来实现“支持传参”的 alias 效果。

通过函数形式来支持参数传递

解决

密钥拷贝例子

alias sci='func sshCopyId(){ssh-copy-id [email protected].$1}; sshCopyId'

sci 90

6dcc5f1dd6c336a2771049c5073e4da9.png