# How to open a .py file in sublime from a terminal console?

• Python
Gold Member

## Main Question or Discussion Point

Hi PF!

To open hello.py in the past I've used gedit hello.py but this opens the file in text editor. I would prefer to use sublime since it has features that are appealing to me. So my question is, how do I open hello.py in sublime from the terminal?

Related Programming and Computer Science News on Phys.org
PeterDonis
Mentor
2019 Award
sublime hello.py doesn't work?

joshmccraney and phyzguy
Gold Member
sublime hello.py doesn't work?
Didn't realize it was this simple; thanks! (it's actually subl hello.py, but thanks)

PeterDonis
Mentor
2019 Award
On Unix-type systems it's a pretty general pattern that <program-name> <filename> at the shell opens the program operating on that file. Of course you still get curve balls like the program name being "subl" instead of "sublime".

joshmccraney
Gold Member
Got it! Fortunately tab kinda takes care of this :)

jedishrfu
Mentor
On mac machine you can say:
Bash:
$$open <filename> and it will select the proper editor or viewer or to be selective: Bash: $$ open -a /Applications/MyFavoriteTextEditor.app <filename>
where MyfavoriteTextEditor is a subfolder in the /Applications folder.

I even added an alias like:
Bash:
$$alias ted=open -a /Applications/MyFavoriteTextEditor.app <filename>$$ ted <filename>