D
D
Dmitry Shelygin2016-09-22 02:38:33
linux
Dmitry Shelygin, 2016-09-22 02:38:33

How to create your own team in Linux?

Is there any way I can create a command that will execute multiple commands in the terminal?
For example, to launch Android Studio, instead of

$ cd /opt/android-studio/bin/
$ ./studio.sh

write simply
$ android

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Error 502, 2016-09-22
@JustJew

To do this, create a permanent alias:
this command will write to the bash config file your permanent own alias to the required command (or several through the ";" sign). those. if you drive in "android" on behalf of your user, then in this case the automatic transition will be made to the desired directory and Android Studio will be launched. I think this is the easiest way :)

A
Andrey Zubkov, 2016-09-22
@zubkov_work

nano /usr/local/bin/android
Paste
#!/bin/bash there
cd /opt/android-studio/bin/
./studio.sh
Then exit and save. And chmod +x /usr/local/bin/android
All

M
Maxim, 2016-09-29
Syomochkin @mak_sim

Alias ​​is just one way to solve your problem. In the broad sense of the word, the Linux shell (bash?) searches for the command that you typed in the console sequentially in all directories specified in the $PATH variable .
For example:

[email protected]:/home/user# echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin

You can include the path to your shell script in the $PATH variable, and then the shell will look for any command you typed, including there. The easiest way to add something to a variable is this:
To make the variable persist between different logins, add the following lines to the .bahs_profile file in your home directory.
PATH=$PATH:/opt/android-studio/bin/
export $PATH

This approach is better than creating an alias because if you need to create another command there will be no need to write a new alias. It is enough to put the executable file in the desired directory.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question