将bash脚本命令添加到终端

时间:2022-01-28 16:23:33

I have studio.sh file in my android-studio/bin folder, which I would like to use as a command in bash (like launching any other normal application).

我在我的android-studio / bin文件夹中有studio.sh文件,我想将其用作bash中的命令(比如启动任何其他普通应用程序)。

I read somewhere that adding this line to ~/.profile should work,

我在某处读到将这行添加到〜/ .profile应该可行,

export PATH=$PATH:/home/goel/android-studio/bin

But it doesn't work. Whats the correct process?

但它不起作用。什么是正确的过程?

3 个解决方案

#1


0  

If you change your PATH in a .profile, you still have to make the shell read the .profile. Starting a new terminal is sometimes not enough (some terminals don't read the .profile), in which case you have to log out and back in.

如果在.profile中更改PATH,则仍需要使shell读取.profile。启动新终端有时是不够的(有些终端不读取.profile),在这种情况下你必须注销并重新登录。

#2


0  

Add the script folder name to PATH environment variable in ~/bash.rc file and you can also create alias for you script in ~/bash.rc and source the /etc/bash.bashrc file, now you can issue your script or alias name in any terminal. Hope this helps.

将脚本文件夹名称添加到〜/ bash.rc文件中的PATH环境变量中,您还可以在〜/ bash.rc中为脚本创建别名并获取/etc/bash.bashrc文件,现在您可以发出脚本或别名在任何终端中的名称。希望这可以帮助。

#3


0  

Is studio.sh executable? Have you tried ./studio.sh inside its containing folder to check whether it runs at all?

studio.sh可执行吗?您是否在其包含的文件夹中尝试了./studio.sh来检查它是否完全运行?

#1


0  

If you change your PATH in a .profile, you still have to make the shell read the .profile. Starting a new terminal is sometimes not enough (some terminals don't read the .profile), in which case you have to log out and back in.

如果在.profile中更改PATH,则仍需要使shell读取.profile。启动新终端有时是不够的(有些终端不读取.profile),在这种情况下你必须注销并重新登录。

#2


0  

Add the script folder name to PATH environment variable in ~/bash.rc file and you can also create alias for you script in ~/bash.rc and source the /etc/bash.bashrc file, now you can issue your script or alias name in any terminal. Hope this helps.

将脚本文件夹名称添加到〜/ bash.rc文件中的PATH环境变量中,您还可以在〜/ bash.rc中为脚本创建别名并获取/etc/bash.bashrc文件,现在您可以发出脚本或别名在任何终端中的名称。希望这可以帮助。

#3


0  

Is studio.sh executable? Have you tried ./studio.sh inside its containing folder to check whether it runs at all?

studio.sh可执行吗?您是否在其包含的文件夹中尝试了./studio.sh来检查它是否完全运行?