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

  • Python
  • Thread starter joshmccraney
  • Start date
  • #1
joshmccraney
Gold Member
2,253
143
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

  • #3
joshmccraney
Gold Member
2,253
143
sublime hello.py doesn't work?
Didn't realize it was this simple; thanks! (it's actually subl hello.py, but thanks)
 
  • #4
41,301
18,940
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
2,253
143
Got it! Fortunately tab kinda takes care of this :)
 
  • #6
14,291
8,332
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>
 

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

  • Last Post
Replies
9
Views
991
  • Last Post
2
Replies
41
Views
2K
  • Last Post
Replies
3
Views
197
Replies
8
Views
598
Replies
12
Views
4K
Replies
27
Views
512
Replies
10
Views
370
  • Last Post
Replies
6
Views
527
Replies
5
Views
811
Replies
4
Views
414
Top