Zsh For Mac Os X



  1. Zsh For Mac Os X 10.8
  2. Zsh-syntax-highlighting Mac Os X
  3. Zsh Mac Os X Iterm2
  4. Zsh For Mac Os X 10.10

I’ve been using zsh for a while, withoh-my-zsh to add a pile of newfeatures to it. Oh-my-zsh is great, and has a lot of useful things in it, butI found it a bit of a pain to keep my fork of it in sync with the mainrepository and another fork that I’d stolen things from. The fact that it wasone giant repository with everything in there didn’t seem quite right to me.Then, I came across zsh-antigen, whichpromises to be to zsh what Pathogen isto Vim. That sounded good to me, so I gave it a try.

The main difference is that instead of having one repository with all theplugins, it lets you load plugins from pretty much any Git repository. Itincludes a special case for the oh-my-zsh repository, so you can load pluginsand themes from there by default. I’d recommend reading the README in theAntigen repository to get the fullstory, but I’ll give a quick overview of how I’ve got mine set up here.

First off, I created my own Git repository, and added the Antigen repository asa submodule. I’ve called mine .zsh-antigen, and it lives in my homedirectory. It’s on Github if you want toclone or fork it.

Next I created my zshrc file, at ~/.zsh-antigen/zshrc. I symlink it into myhome directory to ~/.zshrc.

On lines 1 and 2, I set up a variable to refer to the antigen directory, andthen load the antigen script itself.

On line 4, we tell antigen to use oh-my-zsh by default. That way, we can loadplugins from there with the antigen-bundle command. I use a few, the vagrantand git plugins on all my machines, and I detect Mac OS X and load the osxplugin if I’m on a Mac.

Apple has announced that in macOS 10.15 Catalina the default shell will be zsh. In this series, I will document my experiences moving bash settings, configurations, and scripts over to zsh. ZSH, also called the Z shell, is an extended version of the Bourne Shell (sh), with plenty of new features, and support for plugins and themes. Since it’s based on the same shell as Bash, ZSH has many of the same features, and switching over is a breeze. For Mac OS X users Just go to the terminal preferences Now select your theme whatever you want and then click on the Font Change Button and search for FuraMono, just select it and close the window. Actually zsh is shipped on Mac OS X with completion for open -a. So i guess that the point of this hint is only to make that completion faster for open -a (the built-in one is indeed slow ). Reply to This #.

Zsh For Mac Os X 10.8

I use a couple of bundles that don’t belong to oh-my-zsh, too – these arethe zsh-syntax-highlighting bundle from zsh-users, which adds nice syntaxhighlighting to the command line, and the zsh-history-substring-search bundlethat provides history search when you type part of a command and press the upcursor key. As you can see, if they’re hosted on Github, it’s as easy asspecifying the repos in a “username/repo-name” format.

On line 14, I load a bundle which is local to my config. (It justprovides some path detection to tell me what app I’m in when editing files onmy work computer. These appear in the right prompt.) You can add as many bundlesand as you like, without them having to be part of oh-my-zsh.

Next, on line 16 I apply a theme. This is a theme in the same format asoh-my-zsh, and just specifies what appears in the left prompt (PS1, as in Bashand similar shells) and RPS1 (which is right-aligned and doesn’t normally existin Bash).

Zsh For Mac Os X

We then call antigen-apply last of all, which applies all theprevious configuration. When antigen-apply is called, it will ensure that ithas all the bundles and themes that have been requested. If not, it will go offand download them and cache them locally. This means that the first time youload antigen in a new shell, it’ll wait a few seconds while it goes and grabsthe oh-my-zsh code along with any other bundles you’ve requested.

Underneath this, I place all my useful environment variables, aliases, andinstall things like rbenv, the same way as I used to do in Bash. I find thisway of working to be quite a bit cleaner than oh-my-zsh - the .zshrc I ended upwith in there had quite a lot going on, along with various ‘magic’ things thatI wasn’t keen on. The automatic updating really got on my nerves, even thoughit’s supposed to be convenient. Feel free to grab myrepo and use it as a starting point ifit’s helpful.

When macOS 10.15 Catalina lands this Fall, it will have a new default shell in Zsh. Currently, macOS users have Bash as the default, so why did Apple switch to Zsh… and will it matter?

Both Zsh and Bash are iterations on the Bourne Shell, which was the original command-line interpreter for Unix-based operating systems. Bash, which is short for “Bourne-again shell,” is the most common shell script. Microsoft recently refreshed its Terminal app with a heavy dollop of Bash support.

Apple’s documentation doesn’t provide much insight on why it’s making the switch. It simply says Zsh will be the new default shell for “newly created user accounts,” and that Bash will remain the defualt shell for macOS Mojave and earlier.

In most cases, it won’t make a difference. Zsh and Bash are highly compatible, though Apple cautions us to “be aware that scripts that make use of bashisms may not work properly.” Still, it’s unlikely any changes made in Terminal with Bash would see a system-crashing instance when you switch to Zsh. (If you want to give it a shot, head into the Apple Menu > System Preferences > Users & Groups > click the lock icon > control-click your name in the list of users > Advanced Options > Login shell > Zsh > OK.)

Scripts that are written for Bash can be used in Zsh, but likely require a shebang line like #!/bin/bash or #!bin/bash/sh to execute properly.

Zsh-syntax-highlighting Mac Os X

Like Bash, Zsh supports plugins. It’s also a touch more user-friendly, which is probably one reason Apple moved to it. While fairly basic, Terminal can be intimidating. Zsh can help; it supports automatic change-directory commands, which helps users find files buried deep in a hierarchal tree faster. Zsh also has recursive path expansion, so typing u/lo/b expands automatically to user/local/bin. Spelling errors are caught, and the new shell for macOS Catalina will know cd/donloads was really cd/downloads.

But there’s one more thing to consider: scripting. About Xcode 11 beta, which launches with Catalina, Apple has this to say:

Scripting language runtimes such as Python, Ruby, and Perl are included in macOS for compatibility with legacy software. In future versions of macOS, scripting language runtimes won’t be available by default, and may require you to install an additional package. If your software depends on scripting languages, it’s recommended that you bundle the runtime within the app.

Zsh Mac Os X Iterm2

Apple also writes that Xcode’s debugger, LLDB, has new Python Scripting based on Python 3. The system was shipping Python 2.7, and Apple now says: “Use of Python 2.7 isn’t recommended. This version is included in macOS for compatibility with legacy software. Future versions of macOS won’t include Python 2.7. Instead, it’s recommended that you run python3 in Terminal.”

Zsh For Mac Os X 10.10

There’s still a lot of speculation on the underlying reason for this maneuver. Casual Terminal users won’t notice much of a difference (except that Terminal is perhaps a bit less scary). Power users can still do the things they like, but the platform might require some added manipulation here and there. As for the “why” in all of this, it seems the move to Zsh simply made it easier for Apple to have an extensible, customizable shell environment. We’ll just have to wait to see what that means for future iterations of macOS.





Comments are closed.