阅读694 返回首页    go iPhone_iPad_Mac_apple


How to change default terminal editor

It should be possible to change the default terminal editor by setting an environment variable in .bash_profile.

 

I have tried various permutations of, for instance:

 

export EDITOR=/Applications/TextWrangler.app

 

including:

 

export EDITOR=/Applications/TextWrangler.app/Contents/MacOS/TextWrangler

 

and TextEdit tenaciously holds on as the default editor.

 

"prinetenv" even displays the default at:

 

EDITOR=/Applications/TextWrangler.app

 

Yet, Textedit remains the default editor.

 

Can anyone help me figure this out.  Apple must set the default editor sin some oddball way.

 

Thanks,

 

--Kenoli



The default editor would need to be a unix editor that's compatible with running in the terminal.  To run a gui app from the terminal, you use the open command.

 

TextWrangler has an optional install for terminal commands.  Do the install.  Use the textwrangler command in your edit line.

 

R



I have installed the command line tools for TextWrangler.

 

As far as I can tell

 

open -t

 

in the terminal should open the default editor.  Instead it opens TextEdit.

 

Also, I believe:

 

export EDITOR=/Applications/TextWrangler.app

 

or

 

export EDITOR=/Applications/TextWrangler.app/Contents/MacOS/TextWrangler


should set the default editor to TextWrangler.


open -a /Applications/TextWrangler.app


causes the terminal to open TextWrangler.


The reason this is important here is that I am trying to set TextWrangler as default editor in GIT because there is something in TextEdit that causes characters to read incorrectly in the terminal.


--Kenoli



This worked for me:

1) install textwrangle command line tools.

 

    https://www.barebones.com/support/textwrangler/cmd-line-tools.html

 

    https://apple.stackexchange.com/questions/9587/how-can-i-open-a-text-file-with-te xtwrangler-from-the-terminal-command-line

 

2)

mac $ echo  $EDITOR
/usr/bin/nano
mac $ export EDITOR=edit
mac $ echo  $EDITOR
edit



echo "export EDITOR='twr'">>~/.bashrc

echo "export PATH=${PATH}:/usr/local/bin">>~/.bashrc

ln -s /Applications/TextWrangler.app/Contents/MacOS/TextWrangler /usr/local/bin/twr

echo "[[ -s ~/.bashrc ]] && source ~/.bashrc">>~/.bash_profile

 

Restart the terminal

twr .

should work!

open filename.txt -> should open using textwrangler



最后更新:2017-08-26 06:42:10

  上一篇:go Drivers??
  下一篇:go Short cut not synchronising on my new 10.5" iPad