For an example, I am in the directory Desktop
. I then do cd break
and when I list all files in break, i have for example main.cpp
file. I am trying to be able to go straight from Desktop to opening up main.cpp
using sublime text(using subl
to open it) without getting to break
then doing subl main.cpp
but can't seem to figure it out. This is what I want to do:
/Desktop $ cd break/subl main.cpp
but obviously that won't work. How do I do this and combine everything into one command?
To open a file with a specific program in a directory other than the current working directory, put the command you use to open the file first, then the path to the file. In your case:
You can also use an absolute path, which will work regardless of the current working directory
You can use wildcards in the path. For example I have a file in
I open it like this
If you often open a specific file with a particular program you could make an alias to open it
As @Serg suggested you can also make a symlink to a file buried deep in a directory tree to make it more accessible
Now I can just