0

In a Django project, we are several persons using the same custom bash commands. In the project directory, there are too much of those custom commands. You could see those files in green in the following picture. How could I gather those files into a single directory named 'custom-commands' without affecting their uses? I mean if a user use ./makemessages or if this command if use in the main code, I don't want these changes to affect anything.

  • To be clear, you want to be able to run those commands from any location and place them in a common folder? – Steven Walton Jul 5 '17 at 17:59
  • @StevenWalton Yes, something like this! – user1050421 Jul 5 '17 at 17:59
0

You can accomplish this by the following

1) Place all the commands into a common folder. Maybe something like ~/.django-commands. Make them all executable too.

2) Ensure that all these commands point towards the intended directory. So if you want it to operate in . (current directory) make sure that it points the right direction. If you are pointing to a specific location use absolute path names. Just double check this.

3) You have two options here:

3a) Add ~/.django-commands to your $PATH. Put export "PATH=$PATH:/home/$USER/.django-commands" in your bash (or whatever shell's) rc file. You could also put it in .profile, but I like doing this in the shell's rc file.

3b) Create aliases for the commands.

I suggest 3a, as it will continually update. Commands here will now act just the same way a command in /usr/bin will.

  • We use git to push or pull information from the master branch. How could I make such modification without asking things to the other programmers? In other words, I want they could just pull the commit and that it. And what do you mean by 'Ensure that all these commands point towards the intended directory.'? – user1050421 Jul 5 '17 at 18:13
  • If it is in the $PATH they should be able to pull and have the new versions. What I mean by "Ensure commands point towards intended directory" is that you should double check that they aren't hard coded to wrong directory. Just double check that if you moved it to a random location that it would work as intended. Code is location independent. – Steven Walton Jul 5 '17 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.