首页 > 解决方案 > linux bash终端功能未按命令关闭

问题描述

#webstorm terminal window
alias webstorm='webstorm . &'
#function for opening and running AdminApp
ws(){ gnome-terminal -e webstorm && nohup && exit;};
aa(){ cd Desktop/code/AdminApp; ws; nodemon --exec npm start;};

我的 ide 是 webstorm,我想要完成的是有一个命令来 cd 来更正文件夹打开 ide 然后在本地运行服务器。出于某种原因,我无法关闭 ide 的终端,如果我手动关闭它,它就会关闭 ide。我在一个终端上做所有事情也没有成功。

标签: linuxbashgnome-terminal

解决方案


您正在使用错误的方式nohup gnome-terminal -e

gnome-terminal -e webstorm && nohup && exit当前 shell 中执行三个命令:

  1. gnome-terminal -e webstorm
  2. nohup
  3. exit

nuhop只会在第一个命令成功退出时运行,但只要webstorm正在运行就不会发生。如果webstormexitsnohup开始了,但这现在对您没有帮助,特别是因为nohup期望命令作为参数并且由于您没有提供命令而将失败。

您之前定义的别名对aswebstorm='webstorm . &'没有影响,它接受一个字符串参数并在另一个 shell 中执行该字符串。你必须写出命令。gnome-terminal -e-e

您可能想使用

ws() { nohup webstorm . & }

推荐阅读