哦,我的Zsh具有一个别名的多个命令 [英] Oh My Zsh multiple commands with one alias
本文介绍了哦,我的Zsh具有一个别名的多个命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用哦,我的Zsh ,想知道是否有办法创建一个函数或别名以运行多个命令.举例来说,运行"update"命令将更新特定的gem,但不是全部.
I'm using Oh My Zsh, and was wondering if there is a way to create a function or alias to run multiple commands. Just as an example, running an 'update' command will update specific gems, but not all of them.
推荐答案
您已经发现,可以使用;
在一个别名中链接命令:
As you've discovered, you can chain commands in a single alias using ;
:
alias update_my_gems="echo foo; echo bar"
或者,您可以非常容易地在~/.zshrc
文件中编写函数:
Alternatively, you can write a function very easily in your ~/.zshrc
file:
update_my_gems() {
echo foo
echo bar
}
出于可读性考虑,我个人会为半复杂的事物提供函数.
For readability, I'd personally go for a function for anything that's semi-complex.
这篇关于哦,我的Zsh具有一个别名的多个命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文