0
gvim -O file1.py file2.py file3.py 

The above line launches 3 vim windows vertically side by side. Following the -O argument must be a chain 1 or more files of the format

<file a>.<ext> <file b>.<ext> <file c>.<ext>...

I would like to be able to write something like

go f1.py f2.py f3.py .....fN.py

which would be equivalent to something like

gvim -O f1.py f2.py f3.py .....fN.py

I would also like to be able to do

go <some directory>

Which would unpack all the files names in an arbitrary directory, put them into a chain of filenames as shown above. Finally I would like to be able to save this 'go' command somewhere so that even after closing the terminal I can use the 'go' command.

Adele
  • 39
  • 2
  • 9
  • is it possible to store an alias so it can be used in future sell sessions? I am on a mac – Adele Mar 20 '17 at 06:54
  • 1
    Yes, just save it in your ~/.bashrc. Check out my answer below. If you don't know where your bashrc is, check this out- http://stackoverflow.com/questions/19662713/where-do-i-find-the-bashrc-file-on-mac – Chem-man17 Mar 20 '17 at 06:59

1 Answers1

1

To answer the first part, just set up an alias in your ~/.bashrc

Write this line-

alias go='gvim -O'

Now this will work-

go f1.py f2.py f3.py .....fN.py

For the second part, you need to define a list of files that match a criteria and call that list up as an argument to the command. Do this as-

files=$(ls -v ~/PATH_TO_DIRECTORY/*.py) ; go $files
Chem-man17
  • 1,700
  • 1
  • 12
  • 27
  • 1
    @MattMclaughlin, yes, the second part will work for files of all types. I assumed from your initial question that you only wanted to do this for .py files. Just change `ls -v ~/PATH_TO_DIRECTORY/*.py` to `ls -v ~/PATH_TO_DIRECTORY/*` if you want to see all the files in a directory. – Chem-man17 Mar 20 '17 at 07:39
  • Thanks, I think I wasn't clear initially. I was hoping it would also work for an arbitrary directory. But even if I could do something to the effect of: go that would be fine. Perhaps it already does work for an arbitrary dir, and im just not understanding something. I'm brand new to shell scripting. Sorry to be a pain in the ass. – Adele Mar 20 '17 at 07:44