Why can't I run emacs in X11 - macos

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.

Related

How to get zsh to start automatically in Mac iTerm?

I am sure this is a configuration issue, but I cannot find what is wrong. I have zsh and oh-my-zsh installed on my new Mac view homebrew.
When I start terminal it doesn't load zhs theme or autocomplete unless I run zsh command to start it. After that all works fine.
However, all the aliases I setup in .zshrc file works fine without running zsh and there is no .bashrc file in the machine.
How can I make zsh to start automatically when I open iTerm.
You can change your default shell to zsh.
Using the below command, and type your password
chsh -s /bin/zsh
If you want to use brew managed zsh, you should append /usr/local/bin/zsh to the end of file /etc/shells, then run command chsh -s /usr/local/bin/zsh.
Then reopen your iTerm2, done.

How to open emacs inside zsh terminal on OSX

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.

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.

mvim command in terminal will launch macvim but won't open the file I pass to it as an argument?

I have this weird problem. mvim alias in terminal will launch macvim without problem but if I do, for example
~$ mvim .vimrc
mvim will launch on an empty file and .vimrc will be opened in TextEdit..
how can I fix that? This is pretty annoying!
Don't ask me why, but I had created an alias in .bash_profile. After deleting that useless alias, everything worked!

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.

Resources