Run a different text editor when i type in gedit?
-
12-11-2019 - |
質問
I have recently fallen in love with Sublime Text 2 editor for windows and linux.
In windows I don't have this issue as much, as I don't work from the terminal as often, but I would REALLY like to fully replace gedit
with sublime
in my ubuntu 11.10 install.
I have replaced it as my default program for all text files, but one place I still have issues is the terminal. I have formed the habit of typing gedit filename.txt &
from the command line. Unfortuntately typing in sublime-text-2 filename.txt &
seems to take years longer and I would really appreciate the convenience of fully replacing the keyword gedit
with sublime-text-2
.
Is this possible? If so, how?
I know I can autocomplete to sublime-text-2
with subli
+ TAB, but the habit I have formed in typing gedit
is not proving to be an easy one to break.
I figured since it's linux, anything is possible, but I am not sure where to start with configuing this. Thanks for any tips,
解決
You could just use alias command and add to your .bash_profile
alias gedit='sublime-text-2'
他のヒント
You can just alias
it, I guess.
But that seems a bizarre idea. I'd just change the habit.
Unfortunately, alias does not permit to run the command in background while still passing argument. You can't do:
alias subl="/opt/Sublime/sublime_text $@ &"
You have to use a bash function, like this:
subl() { /opt/Subl2/sublime_text "$@" & }
add this to your bashrc and you will be able to start sublime text in detached mode and give file names to open.