简体   繁体   English

无法在Mac终端上创建别名以在新窗口中打开emacs

[英]can't make an alias on mac terminal to open emacs on a new window

I have just taken a C programming course. 我刚上过C编程课程。 The computers we used in class were set up such that by typing the command: emacs filename.c the linux terminal would open a new emacs window on the desktop. 我们在课堂上使用的计算机已设置为通过键入命令: emacs filename.c ,Linux终端将在桌面上打开一个新的emacs窗口。
Now I have a Mac and tried to make an alias to achieve the same by typing the following command in the terminal: 现在我有一台Mac,并尝试通过在终端中键入以下命令来创建别名以实现相同的目的:

alias emacs="/Applications/Emacs.app/Contents/MacOS/Emacs "$@""   

I found that on an older question ( How to launch GUI Emacs from command line in OSX? ). 我发现这是一个较旧的问题( 如何从OSX中的命令行启动GUI Emacs? )。 The command works but after closing the terminal and then re opening it if I type emacs filename.c it does not work anymore. 该命令有效,但是在关闭终端然后重新打开后,如果我键入emacs filename.c它将不再起作用。 So is there a way to create the alias permanently? 那么有没有办法永久创建别名?

Try adding it to your profile: 尝试将其添加到您的个人资料:

echo 'alias emacs="/Applications/Emacs.app/Contents/MacOS/Emacs "$@""' >> ~/.profile

The file ~/.profile is run when you log in, so that alias will be automatically created each time you log in. 文件〜/ .profile在您登录时运行,因此每次登录时都会自动创建别名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM