zsh:创建文件并在编辑器中打开

时间:2019-04-26 14:56:53

标签: terminal sublimetext3 zsh

有人知道任何巧妙的快捷方式来创建文件并同时在编辑器(在我的情况下为Sublime)中打开它吗?

类似touch some/nice/file.txt | st ...touch some/nice/file.txt && ...something

({st是我的崇高快捷方式,可以接受自变量)

touch some/nice/file.txt && st some/nice/file.txt当然可以,但是涉及到重复文件名,如果没有它,这样做会很不错!

预先感谢

1 个答案:

答案 0 :(得分:0)

您可以在.zshrc中放置一个别名,以将其缩短为您想要的名称。只需添加一行

alias to='to(){ touch $1; st $1 }; to '

到您的zshrc。

现在,如果您在shell中键入“ to some / nice / file.txt”,它应该制作文件并打开它。您需要重新加载一次终端或使用'source .zshrc'才能正常工作。