-1

For example, if you install git and type git in the terminal, the git program will respond with an output, no matter what directory you are in. Let's say I make a python script - how can I make it respond to !test, for example, without having to run my program and only be able to use the program and no other commands? I understand I have done a bad job at explaining this, but I hope it's clear enough. Thanks

Edit1: I'm not sure if this helps, but I'm running Xubuntu.

Thomas Jowsey
  • 47
  • 1
  • 8

1 Answers1

1

You would add the scripts directory to your path variable.

For example, I have a scripts directory in my home directory.

I add a path entry to my .bashrc like so:

export PATH=$PATH:$HOME/scripts

Then invoke the script within the scripts directory by its filename.

Use #! at the top of the script file to provide the path to the binary you want to execute the script with.

  • Python: #!/bin/python
  • Bash: #!/bin/sh.
modle13
  • 1,242
  • 2
  • 16
  • 16
  • Don't forget to `source ~/.bashrc`. And change the file permission to allow execution `chmod 765 path/to/script/file`. Some prefer `700` instead. – Prav Nov 27 '17 at 21:22