How to open emacs inside zsh terminal on OSX - macos

First of all, I use OSX.
When I use default bash and type emacs in terminal, it will open emacs inside terminal.
But when I switch to zsh, this operation will call my emacs app.
I have tried use emacs -nw, but the terminal just flash and nothing else happen.
Thanks for help me.

Related

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.

Why can't I run emacs in X11

I have Emacs installed as an app on my computer and I set a shortcut in my bash_profile as well.
alias emacs='/Applications/Emacs.app/Contents/MacOS/Emacs'
However, x11 doesn't find emacs but when I use Terminal, it runs just fine.
Why could this be?
When I start an xterm in XQuartz, the ~/.bash_profile file is not sourced for some reason. Try putting the alias into ~/.bashrc instead.

How to open emacs gui/ide from mac terminal?

I'm trying to open files up on emacs outside of the terminal. I prefer a gui/ide environment when I code instead of doing it through a terminal. I initially thought that typing emacs filename.py would open that file through Emacs.app, however it only allowed me to edit the file through the terminal. When this didn't work, I looked into editing the .profile and .emacs files in my home directory but this was to no avail.
Maybe this is more intuitive than what I've read but I can't seem to figure it out. Any help is appreciated.
Assuming you have Emacs installed from Homebrew like this:
brew install emacs --with-cocoa
Just type the following command to open Emacs.app from terminal:
open -a Emacs filename.py
If you want all files opened in the same frame, instead of new frames, put this into your .emacs file:
(setq ns-pop-up-frames nil)
The best way to open files in Emacs from the terminal is the emacsclient command, which will open the file in your existing Emacs app (preventing startup time). If you're on OSX and you installed Emacs through Homebrew, the emacsclient binary will already be set up. (In your Emacs config, you have to include (server-start) somewhere.)
If you actually want to spin up a new GUI app instance instead, you can set up your own shell script and put it in your PATH somewhere before the existing emacs binary. It sounds like you're using Homebrew, which sets up the emacs binary as the following shell script:
#!/bin/bash
/usr/local/Cellar/emacs/24.3/Emacs.app/Contents/MacOS/Emacs -nw "$#"
The -nw is what prevents Emacs from opening in GUI mode. You can make your own emacs shell script and leave out -nw:
#!/bin/bash
/usr/local/Cellar/emacs/24.3/Emacs.app/Contents/MacOS/Emacs "$#"
To do what you want, you'd need to find the location of the actual binary contained in Emacs.app, and use that as the command instead of emacs. Most likely, it's at
/path/to/Emacs.app/Contents/MacOS/Emacs
Which, if you have Emacs.app in your Applications folder, as would be typical, would be
/Applications/Emacs.app/Contents/MacOS/Emacs
To set it up with a shorter command to use, you could try adding to your .profile (I don't know what shell you use) the following line, or whatever equivalent it has for your shell (This works for bash and zsh, at least):
alias emacsgui='/Applications/Emacs.app/Contents/MacOS/Emacs'
The modern way to go about this is by installing Emacs using Homebrew Cask:
brew cask install emacs
Source: this comment by Homebrew project leader Mike McQuaid, which reads:
Cocoa support for Emacs will not be accepted. This is provided by brew cask install emacs.
One should link emacs to /Applications if not already done,
brew linkapps emacs
to link the emacs to symlink emacs installed in Cellar. Once symlinked, you can open emacs by
open -a emacs
as already pointed out by #katspaugh
brew doesn't have cask command anymore.
I used brew install emacs and I can find Emacs app installed in my application directory.
You can also head to https://emacsformacosx.com and download the .dmg file.

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

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

Vim in Emacs

The question does not refer to some Vim-mode in Emacs, but to Vim inside Emacs. I am not waging any Editor-war. I just want to use Vim in Emacs.
http://dl.getdropbox.com/u/175588/emacs.png
You can get to Vim in Emacs with commands "M-x term" and "vim".
When I am using the Vim-Emacs, the typing is awkward. There are odd signs, such as "4m", "4mm" and "^?^?". The backspace and the x-button in insert mode do not work. The odd signs emerge when I press the latter keys. So
How can I get Vim properly working in Emacs?
[Updated Information]
The malfunctioning Vim-Emacs is at least in the following OSs:
Mac OS 10.5.6
What you're seeing is that the terminal setting $TERM in your shell/Vim session doesn't match what the EMACS terminal is doing. Mine works fine, with the exception that the delete key is mapped to DEL, 0x127, while Vim wants ^H, 0x8. Mine shows the $TERM setting to be "eterm-color".
Check what you have as $TERM
$ echo $TERM
and check the Vim docs for how to fix the backspace issue.
For backspace,
stty crt erase <CTRL-V><BACKSPACE>
Worked for me.
As for the rest, I don't know. Suppose it is something the shell outputs that the terminal doesn't handle. (Never used emacs 'term' before... prefer iTerm or Terminal.app for shell-related stuff. emacs 'term' has been called an "imperfect terminal emulator")

Resources