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

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.

Related

I accidentally delete zsh from /bin folder in Mac

I delete the zsh binary from bin folder , so when i try to change my shell i get this :
chsh: WARNING: shell '/bin/zsh' does not exist
I don't know how to reinstall zsh shell and MacOs come with zsh by default.
The easiest thing would be to install zsh using brew (which will install it in /usr/local/bin/zsh) and then symlink it to /bin/zsh.
There are obvious more ways to fix this, but this seems (to me) to be the simplest.
I fixed that problem using mac tools. I invested only about 30 min of my time whith the reinstall option. It's obviously there is a way to generate a zsh binary, but I find easy reinstall the osx due to Osx come by default with the zsh binary and brew install doesn't install the zsh binary. On the other hand, there must a way to install zsh from scratch but I think find the correct way would take more time

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

how to install emacs23 on Mac OSX without GUI

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

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