I have a highest frequently used command, which is
singularity exec --bind $PWD ~/triqs.simg python3 xxx.py
It's tedious to type such a long command every time I need. Is there any convenient way to set it as a Linux variable that allow me to call with different xxx.py
suffix?
CodePudding user response:
Create a shell script runPython.sh with following content.
singularity exec --bind $PWD ~/triqs.simg python3 $1
If this does not work then provide full path for all the executables used inside the shell script.
CodePudding user response:
I recommend you to use bash aliases to make the command much shorter
Creating aliases in bash is very straight forward. The syntax is as follows:
alias alias_name="command_to_run"
An alias declaration starts with the alias keyword followed by the alias name, an equal sign and the command you want to run when you type the alias. The command needs to be enclosed in quotes and with no spacing around the equal sign. Each alias needs to be declared on a new line.
The ls command is probably one of the most used commands on the Linux command line. I usually use this command with the -la switch to list out all files and directories, including the hidden ones in long list format.
Let’s create a simple bash alias named ll which will be a shortcut for the ls -la command . To do so type open a terminal window and type:
alias ll="ls -la"
Now, if you type ll in your terminal, you’ll get the same output as you would by typing ls -la.
The ll alias will be available only in the current shell session. If you exit the session or open a new session from another terminal, the alias will not be available.
To make the alias persistent you need to declare it in the ~/.bash_profile or ~/.bashrc file.