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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
As you've discovered, you can chain commands in a single alias using ;
:
alias update_my_gems="echo foo; echo bar"
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.
回答2:
If there are many commands, I find it useful to alias the execution of a .sh file located on my home directory
alias start_containers="./start-containers.sh"
To throw the alias inside the config file, you can do
echo alias start_containers="./start-containers.sh" >> ~/.zshrc