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

  • Python
  • Thread starter joshmccraney
  • Start date
  • #1
joshmccraney
Gold Member
1,921
92

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?
 

Answers and Replies

  • #2
PeterDonis
Mentor
Insights Author
2019 Award
29,591
8,883
sublime hello.py doesn't work?
 
  • Like
Likes joshmccraney and phyzguy
  • #3
joshmccraney
Gold Member
1,921
92
sublime hello.py doesn't work?
Didn't realize it was this simple; thanks! (it's actually subl hello.py, but thanks)
 
  • #4
PeterDonis
Mentor
Insights Author
2019 Award
29,591
8,883
Didn't realize it was this simple
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". :wink:
 
  • Like
Likes joshmccraney
  • #5
joshmccraney
Gold Member
1,921
92
Got it! Fortunately tab kinda takes care of this :)
 
  • #6
11,794
5,402
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>
 

Related Threads on How to open a .py file in sublime from a terminal console?

Replies
2
Views
8K
Replies
1
Views
1K
Replies
1
Views
748
Replies
9
Views
16K
Replies
5
Views
198
  • Last Post
Replies
9
Views
3K
Replies
20
Views
7K
  • Last Post
Replies
6
Views
2K
Replies
4
Views
3K
Top