英文:
How to run a .sh script in terminal by double-clicking?
问题
I have a .sh script that I would like to run in a terminal window upon being double-clicked. This is the contents of the script:
#!/bin/sh
cd "$(dirname "$(readlink -fn "$0")")"
java -Xmx1024M -Xms1024M -jar minecraft_server.1.19.jar nogui
Is there any way to modify the script so that the output could be displayed back to the user?
I have looked online for any potential solutions, and the closest I have found is this article, which takes advantage of options that are not provided to me by my distro (Kubuntu). I have also attempted to set the file to, by default, open with a terminal, however the script does not run.
英文:
I have a .sh script that I would like to run in a terminal window upon being double-clicked. This is the contents of the script:
#!/bin/sh
cd "$(dirname "$(readlink -fn "$0")")"
java -Xmx1024M -Xms1024M -jar minecraft_server.1.19.jar nogui
Is there any way to modify the script so that the output could be displayed back to the user?
I have looked online for any potential solutions, and the closest I have found is this article, which takes advantage of options that are not provided to me by my distro (Kubuntu). I have also attempted to set the file to, by default, open with a terminal, however the script does not run.
答案1
得分: 0
我认为一种解决方案是在这里创建一个 *.desktop
文件:
$ cat path-to-script.desktop
[Desktop Entry]
Type=Application
Terminal=true
Name=Click-Script
Icon=utilities-terminal
Exec=gnome-terminal -e "bash -c './script.sh;$SHELL'"
Categories=Application;
英文:
I think one solution is crating a *.desktop
file here:
$ cat path-to-script.desktop
[Desktop Entry]
Type=Application
Terminal=true
Name=Click-Script
Icon=utilities-terminal
Exec=gnome-terminal -e "bash -c './script.sh;$SHELL'"
Categories=Application;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论