-1

I assume that this question was asked many times but i didn't find suitable solution. Every time when i open my shell i need to execute commands to open my working directory enable virtualenv and open file. For example

cd storage/predictions #open project directory
. env/bin/activate  #activate virtual environment 
cd forecast  #open directory
vim file.py    #open a file 

am i can to execute above commands in more convinience mode such as nest these several commands in one. For example

cd storage/predictions & . env/bin/activate & cd forecast & vim file.py 

Thank in advance

1 Answers1

0

If you are going to change your environment, you need to "source" the command, not just run a script. That's because a child script is never permitted to change its parent's environment.

Sourcing (dot files) are mainly used for shell start-up, but there is nothing to stop you using them locally.

Make a file called something like "myEnv"in your home directory, containing those commands. You don't need the directory to be on your path, and the file does not need to be executable. You could have several for different start-ups.

First thing when your terminal opens, type: . myEnv

I used to keep a vi session open in a small window, for a file in my home directory called Help. I pasted any frequently-used or complicated commands in there, and saved it occasionally. Just post-its as reminders, and to eliminate typos.

Paul_Pedant
  • 8,679