how to install emacs23 on Mac OSX without GUI - macos

What's the best way to install Emacs23 on Mac OSX. I want to launch it from the terminal, without any X-windows or other GUI business.
I tried http://emacsformacosx.com/ but that launches a Mac application. I just want the text-only version inside of Terminal.
Thanks.

I would think that any GNU Emacs would accept the -nw command line option; the http://emacsformacosx.com/ version included.
You can then use a shell alias or wrapper script to do that by default.
e.g. for bash, you could use alias emacs="emacs -nw" (and add it to your .bashrc file to make it persistent).

if you use macports:
sudo port install emacs

Homebrew has Emacs packages available.

If you use fink
$ fink install emacs23-nox
Or install the general package (emacs23) version and invoke it with
$ emacs -nw

Related

Update OSX Vim using MacVim

I'm trying to update Vim (for use in Terminal) on my Mac. It's currently running version 7.3, but YouCompleteMe requires Vim 7.3.584, and won't run even though it's installed.
I've tried using a Vim alias in my .bash_profile:
alias vim='/Users/Conor/Applications/MacVim.app/Contents/MacOS/Vim'
However none of my Vim plugins are launched when I run Vim like this, any my vimrc file isn't recognised either.
How can I get this alias to recognise my existing Vim settings? Or is there a better way of upgrading Vim for mac?
The *.tbz that you downloaded from the official page contains a mvim script.
Once you have moved that script somewhere in your $PATH you can start the MacVim GUI like this:
$ mvim filename
and the MacVim CLI like that:
$ mvim -v filename
From there the only thing you need is to change your alias to point to mvim:
alias vim='mvim -v'
The original built-in Vim and its runtime files stay untouched, MacVim uses its own runtime files located in the MacVim.app bundle and both honor your personal config (assuming they are located where they should be: ~/.vimrc and ~/.vim/).
Quick, clean and painless.
If you installed MacVim with HomeBrew you can use
brew install macvim --override-system-vim
If you just want pure vim with python support do:
brew install vim --override-system-vim --HEAD
I had the same issue as you, but this worked like a charm. You complete me works perfectly after this.

Run gedit on OSX Mavericks?

The Version of Gedit on the gnome.org site does not seem to run on OSX Mavericks. Is there any way to fix this?
When I tried it, the problem was the version of libxml2 packaged with gedit.
Use the command "brew install libxml2"
then cp /usr/local/Cellar/libxml2/2.9.1/lib/libxml2.2.dylib /Applications/gedit.app/Contents/Resources/lib/.
In the current version of brew, the directory has changed to 2.9.2 so:
then cp /usr/local/Cellar/libxml2/2.9.2/lib/libxml2.2.dylib /Applications/gedit.app/Contents/Resources/lib/.
Having MacPorts installed and comments from above I was able to simply rm /Applications/gedit.app/Contents/Resources/lib/libxml2.2* and it used the system/macports library instead of the bundled one without error.
Just to Revise:
Having macports installed correctly. (If you just updated from e.g. OSX Lion you need to migrate macports to your new Maverics OSX System, https://trac.macports.org/wiki/Migration)
Downloading gedit-3.2.6-3
sudo port install libxml2
and rm /Applications/gedit.app/Contents/Resources/lib/libxml2.2*
Open gedit and start Coding!
For my 13-inch, Early 2011 Macbook pro it worked just fine.
--
If you want to use gedit from Terminal:
add
alias gedit="open -a gedit"
to
~/.bash_profile
Gedit 2.30.2 works.
But your own plugin won't work on Gedit 2.30.2.
I dont know what your goal is, but i found a easier way with another program. If installing all of this starts to get tiersome (that's what i figured out at least, since xcode needed downloading and tampering), i found sublime text 2 to work very nicely.
I found that the version of "libxml2.2.dylib", distributed with Gedit 3.2.6 is outdated.
Install "Xcode" from the App Store (if you have not already done so), then:
$ cp -p /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/libxml2.2.dylib /Applications/gedit.app/Contents/Resources/lib/libxml2.2.dylib
One solution (I'm still interested in others) is the following:
The latest version of Gedit (3.2.6-3)for OSX on the Gnome.org website crashes.
The older Gedit 2.30.2 still runs.
try version 2.26.3 of Gedit – it’s working for me on MOJAVE !
http://ftp.gnome.org/pub/GNOME/binaries/mac/gedit/2.26/
Darek
If I am guessing correctly, your aim is a GUI Text editor for convenience.
open /path/to/file
performs the same action as of double clicking on the file from Finder
Also if you want to use it with a specific application like sublime text
open -a 'Sublime Text' /path/to/file

upgrading console emacs (/usr/bin/emacs) on Mac

I extensively use /usr/bin/emacs in Terminal.
I have Emacs 22 and I'd like to upgrade it to 23. I wonder how to do it.
Googling "emacs download mac" gives me Emacs.app which has its own window and user interface, but I don't want that.
I am not sure how I have /usr/bin/emacs in the first place, maybe it came with Mac OS?
You can run the Emacs.app version in a terminal like this:
/Applications/Emacs.app/Contents/MacOS/Emacs -nw
In my .cshrc file, I use an alias to make this easier to invoke:
alias enw '/Applications/Emacs.app/Contents/MacOS/Emacs -nw'
It is a standard editor included with OS X and a lot of other *nix systems along with vi/vim, and pico. Personally i wouldnt upgrade the pre-installed one. I would install from Macports, Fink, or Homebrew or compile from source myself to a different location (like /usr/local).
Install emacs from macports.
% sudo port install emacs
Then launch it from the terminal
Or you can install Emacs.app, follow the instructions here to create a ~/bin/emacs script and then launch as emacs -nw or any other options.
#!/bin/sh
exec /Applications/Emacs.app/Contents/MacOS/Emacs "$#"
I was on this same search and ended up installing with Homebrew so I could get the latest version along with several libraries, as described in this answer at the Emacs Stack Exchange site:
Nowadays, I use just GNU Emacs snapshot builds. These have reasonably good OS X support, and are by far the easiest to install, and best supported by the community.
I used to get them from Emacs for Mac OS X, but now I use Homebrew, because it supports more libraries, notably GNU TLS for encrypted network connections.
All in all: Use brew install emacs --HEAD --use-git-head --with-cocoa --with-gnutls --with-rsvg --with-imagemagick :).
(Note that GNU Emacs is what comes preinstalled on Mac OS X, at least on mine as of 10.10.5)
This added a new Emacs binary at /usr/local/bin/emacs, leaving the existing installation and /usr/bin/emacs in place.
I created a symlink in /usr/local/bin pointing to the new version of emacs which was in Applications/Emacs.app/Contents/MacOS/
For those who installed Emacs from source (or any other way that doesn't overwrite command line called emacs) and want to use this version in the command line, I suggest one of these two approaches:
ln -s ~/path/to/cloned/emacs/src/emacs /usr/local/bin/emacs
make sure /usr/local/bin is in your $PATH and located before /usr/bin, by executing echo $PATH
if it is not, add line export $PATH=/usr/local/bin:$PATH to the file ~/.bash_profile, then refresh $PATH by executing in the terminal source ~/.bash_profile
add ~/path/to/cloned/emacs/src to your $PATH.
for example, add line export $PATH=~/path/to/cloned/emacs/src:$PATH to the file ~/.bash_profile, then refresh $PATH by executing in the terminal source ~/.bash_profile
And yes, MacOS is shipped with many packages pre-installed. But, unfortunately, usually with outdated ones and no official package manager to easily upgrade those libraries. That's actually why we have Homebrew, Macports, maybe others: they serve us as MacOS package managers.

Installing vim with ruby support (+ruby)

I'm trying to get command-t installed for vim but my current version of vim doesn't have the (+ruby) flag. The command "which ruby" shows that ruby is installed.
What do I need to do in order to activate the +ruby flag in vim?
Also, what does the +ruby flag technically mean?
Some package provides vim-ruby on Ubuntu, for example vim-nox.
simply:
sudo apt-get install vim-nox;
will get you vim with ruby, as well as compiled in "support for scripting with Perl, Python, Ruby, and TCL but no GUI."
sudo apt-get install vim-rails
will install a "selection of vimscripts that make editing Ruby on Rails applications extremely easy." but as it depends on vim-full and vim-addon-manager, it will also install the vim-gnome version of the GUI, that is "a version of vim compiled with a GNOME2 GUI and support for scripting with Perl, Python, Ruby, and TCL."
I think "Compiling Vim With Ruby Integration On Snow Leopard" might actually help. I'm on exactly same boat at the moment.
Ok... got it to work. Took me like half hour or so.
This should help (I got Ubuntu):
sudo apt-get install mercurial
hg clone https://vim.googlecode.com/hg/ vim
cd vim
./configure --enable-rubyinterp
make
sudo make install
To test if things look fancy:
vim --version | grep ruby
Should return something like:
-python3 +quickfix +reltime -rightleft +ruby +scrollbind +signs +smartindent
Ruby should have plus now. Another trick to test it - enter vim and hit :ruby 1. Should not fail.
On mac os x, assuming you have Homebrew installed:
brew install https://raw.github.com/Homebrew/homebrew-dupes/master/vim.rb
This version of vim has ruby support enabled
Source: http://blog.jerodsanto.net/2011/08/brew-install-vim/
EDIT: edited the url, thanks #david-xia for mentioning the change
UPDATE: Apparently, homebrew vim now comes with ruby support enabled by default so you just need to do brew install vim (see comment below)
If there isn't a Ruby enabled Vim available for your operating system, you'll have to recompile. This is very easy and there are some instructions on the Vim website I believe. If you're on Linux, you use configure to choose what you want. Have a look at the output of:
./configure --help
in the Vim source directory. Read it carefully, there are a lot of options in there. The main one you want is --enable-rubyinterp, but you may also want to add --with-features=HUGE among others. As I said, read the help provided.
when you run ./configure you need to add the folowing --enable-rubyinterp
./configure --enable-rubyinterp
On Mac OS X, I find that the easiest is to install MacVim with brew install macvim which includes +ruby. And then symlink /usr/local/bin/vim to /usr/local/bin/mvim. That way to get a recent Vim version, with the huge feature set, +ruby, both GUI and command line vim just using the standard HomeBrew repository. No need for external repository like in Pierre answer
To avoid issues it's better to use the use the system ruby during installation so:
rvm use system
brew install macvim
ln -s /usr/local/bin/mvim /usr/local/bin/vim
Flag +ruby means that vim is compiled with ruby support and linked against ruby interpreter library. You cannot get this flag without recompiling vim or installing another version which is compiled with this flag.
Pulling the vim source using Mercurial and changing into the directory will give you the ability to configure your vim install before you compile it.
hg clone https://vim.googlecode.com/hg/ vim
cd vim
./configure --enable-rubyinterp
The --enable-xxinterp option can be used for Python, Perl, or any other language that Vim will support. Just type it in where the xx is and it will work.
Running the help option with the configure command will allow you to see all of the configuration options.
./configure --help
Under Windows you can install Vim from here:
http://sourceforge.net/projects/cream/files/Vim/
Version 7.3.3 seems to be compiled with Ruby support (see release notes file). The newest 7.3.x currently is not.
Installing vim-rails will add Ruby (+ruby) support. I just tried and verified that it works and Command-T runs fine now.
sudo apt-get install vim-rails
If you are using MacPorts in OSX, you may try
sudo port install vim +ruby
To specify a different ruby version, you may try
sudo port install vim +ruby18
or
sudo port install vim +ruby19
It looks like you need to have ruby installed before install vim-nox.
This works for me on Ubuntu 18.10
sudo apt-get install ruby rubygems vim-nox
Source: https://junegunn.kr/2013/09/installing-vim-with-ruby-support
If you are lazzy and don't want to recompile you can try to find a package with a vim version including ruby. On debian it's vim-ruby so something like
apt-get install vim-ruby
might work. (I can't try it, I m on mac. On mac , MacVim come with ruby enabled)

How to run mvim (MacVim) from Terminal?

I have MacVim installed and I am trying to set it up as the editor for Git (version control), but I can't run 'mvim' from the command line as it isn't recognised. How do I setup mvim so I can run it from Terminal?
I don't think I'd to add anything to the path, did
brew install macvim
mvim -v
should then open macvim in the terminal, you can also go ahead and alias that
alias vim='mvim -v'
There should be a script named mvim in the root of the .bz2 file. Copy this somewhere into your $PATH ( /usr/local/bin would be good ) and you should be sorted.
If you go the brew route, the best way to install would be:
brew install macvim --with-override-system-vim
That will provide mvim, vim, vi, view, etc. in /usr/local/bin (all symlinked to the copy in the Cellar). This also removes the need to create any aliases and also changes your vi, vim, etc. to all use the same Vim distribution as your MacVim.
In addition, if you want to use MacVim (or GVim) as $VISUAL or $EDITOR, you should be aware that by default MacVim will fork a new process from the parent, resulting in the MacVim return value not reaching the parent process. This may confuse other applications, but Git seems to check the status of a temporary commit message file, which bypasses this limitation. In general, it is a good practice to export VISUAL='mvim -f' to ensure MacVim will not fork a new process when called, which should give you what you want when using it with your shell environment.
If you already have macVim installed: /Applications/MacVim.app/Contents/MacOS/Vim -g will give you macVim GUI.
just add an alias.
i use gvim because that is what i use on linux for gnome-vim.
alias gvim='/Applications/MacVim.app/Contents/MacOS/Vim -g'
Assume MacVim is installed in the Application folder.
Instead of adding MacVim path to your environment, create a link by typing this in terminal:
sudo ln -s /Applications/MacVim.app/Contents/bin/mvim /usr/local/bin/mvim
Then, open a new terminal window/tab and type mvim.
If you have homeBrew installed, this is all you have to do:
brew install macvim
brew linkapps
Then type mvim in your terminal to run MacVim.
Here's what I did:
After building Macvim I copied mvim to one of my $PATH destinations (In this case I chose /usr/local/bin)
cp -v [MacVim_source_folder]/src/MacVim/mvim /usr/local/bin
Then when you invoke mvim it is now recognised but there is an annoying thing. It opens the visual MacVim window, not the one in terminal. To do that, you have to invoke
mvim -v
To make sure every time you call mvim you don't have to remember to add the '-v' you can create an alias:
alias mvim='mvim -v'
However, this alias will only persist for this session of the Terminal. To have this alias executed every time you open a Terminal window, you have to include it in your .profile
The .profile should be in your home directory. If it's not, create it.
cd ~
mvim -v .profile
include the alias command in there and save it.
That's it.
I'm adding Bard Park's comment here for that was the real answer for me:
Since mvim is simply a shell script, you can download it directly from the MacVim source at GitHub here: http://raw.github.com/b4winckler/macvim/master/src/MacVim/mvim
I'd seriously recommend installing MacVim via MacPorts (sudo port install MacVim).
When installed, MacPorts automatically updates your profile to include /opt/local/bin in your path, and so when mvim is installed as /opt/local/bin/mvim during the install of MacVim you'll find it ready to use straight away.
When you install the MacVim port the MacVim.app bundle is installed in /Applications/MacPorts for you too.
A good thing about going the MacPorts route is that you'll also be able to install git too (sudo port install git-core) and many many other ports. Highly recommended.
This works for me:
λ brew link --overwrite macvim
Linking /usr/local/Cellar/macvim/8.0-146_1... 12 symlinks created
For Mac .app bundles, you should install them via cask, if available, as using symlinks can cause issues. You may even get the following warning if you brew linkapps:
Unfortunately brew linkapps cannot behave nicely with e.g. Spotlight using
either aliases or symlinks and Homebrew formulae do not build "proper" .app
bundles that can be relocated. Instead, please consider using brew cask and
migrate formulae using .apps to casks.
For MacVim, you can install with:
brew cask install macvim
You should then be able to launch MacVim like you do any other macOS app, including mvim or open -a MacVim from a terminal session.
UPDATE: A bit of clarification about brew and brew cask. In a nutshell, brew handles software at the unix level, whereas brew cask extends the functionality of brew into the macOS domain for additional functionality such as handling the location of macOS app bundles. Remember that brew is also implemented on Linux so it makes sense to have this division. There are other resources that explain the difference in more detail, such as What is the difference between brew and brew cask?
so I won't say much more here.

Resources