Can't seem to change default editor in OSX Lion terminal - bash

I can't seem to change the default bash editor in OSX Lion terminal.
I've tried setting:
export EDITOR='<editor symlink with parameter>'
in both ~/.bashrc & ~/.bash_profile . The symlink is subl, and the parameter is -w.
from the prompt it is:
subl -w
I have restarted terminal after each but every time I enter:
edit test-file.md
it opens TextWrangler (not the editor I've set). I've tried opening the symlink from the command line with no problem. I realize that I should probably just get used to typing the symlink, but the anal side of me wants to know why I can't set the default editor.
Any help with this trivial problem would be appreciated, thanks in advance!

I'm not even sure what edit command is. i don't have in on my Mac OS X Lion. Whatever it is, sounds like it ignores the EDITOR env variable and uses your MacOS X application settings.
What you want can be accomplished with the alias shell command though:
alias edit=/path/to/vim

Related

How to create terminal shortcuts (ssh shortcuts) on Mac OS Catalina (zsh)

Can't find many resources on this. With Mac OS Catalina, the default shell switched from bash to zsh.
I want to edit .zshrc so I can add some ssh shortcuts (and avoid having to copy/paste my ssh command from a text file every morning). I can't find .zshrc anywhere. Do I have to create it? Am I headed in the wrong direction? Any help appreciated.
.zshrc should be under /Users/username/
Try ls -a in terminal if you haven't to show hidden files. If .zshrc isn't there, you need to make one.

Set path to applications for vim on mac capitan

I have used vim to make small scripts in python and typesetting things in LaTeX. So it is very useful to run applications from vim by typing :!python or :!pdflatex etcetera. But after upgrading to el capitan, this seems not to work anymore, get message like /bin/bash: pdflatex: command not found. But the funny thing is that it is possible to run the applications directly from terminal. Anyone that know how to set the correct that for vim as well?
$PATH variable not properly set in gvim/MacVim when it is opened from the finder
first check :!echo $SHELL and see if SHELL is set to bash or not
then try to set your path in your ~/.bash_profile?
export PATH=<dir_contains_pdflatex>:$PATH

Setting the default terminal editor on a Mac running Yosemite or El Capitan

I have read any number of posts explaining how to set the default editor for the terminal on a mac o stackoverflow. They all describe the same thing inserting a line in .bash_profile (or sometimes .bashrc) like:
export EDITOR='/Applications/TextWrangler.app'
or:
export EDITOR='/Applications/TextWrangler.app/Contents/MacOS/TextWrangler'
Nothing works. The terminal continues to default to TextEdit.
Has apple set this profile somewhere else in a way that overrides .bash_profile?
Can someone help me with this?
According to the man page for open:
-e Causes the file to be opened with /Applications/TextEdit"
In any case, open is an OS X command which will use the associations that are set for the file, the same as Finder does. The only things that will obey EDITOR are command line programs designed to run in a Unix environment.

emacs automatically open in mac

I was setting up with emacs on my macbook. In order to open the emacs from command line, I was follow other's suggestion to add an emacs script to my /usr/bin.
Now I can open graphic emacs from command line, but the problem is that every time when I open the terminal, the emacs is automatic run. I don't know why this happened.
Here is the script I added:
#!/bin/sh
/Applications/Emacs.app/Contents/MacOS/Emacs "$#"
I also use chmod +x /usr/bin/emacs after the script was added.
Please tell me what cause the problem happens.
If your using the standard OS X terminal, look under preferences->profile and the shell tab and make sure there isn't something set in the run on startup option.
If your using another terminal, such as iTerm, check the profiles.

Terminal in OSX Lion looks different after unknown command

I spent some time today installing Ruby, Rails and other web development stuff through homebrew and rvm. But somewhere i must have put the wrong command in the terminal since my terminal on OS X Lion (same with both standard terminal and iTerm2) now looks weird.
How do I get rid of that red tilde and black arrow and get it back how it looks as default?
As I am a beginner at terminal commands I would appreciate your help.
it seems like PS1 has been changed.
what you can do now is to change it back, or simply delete it to return to default.
in terminal, do the following:
cd ~
grep "export PS1" .*
then you will see some outputs, it might be in .profile or .bashrc, (just ignore the history one)
you can use whatever to open the file. or just open .filename in terminal, delete the line with export PS1, save, relogin. the problem shall be resolved.

Resources