This post is part 6 of 6 in the series Bash to Zsh

Having used Zsh rather than Bash for over a week it was time to make the move permanent by migrating my shell customisations from ~/.bashrc to ~/.zshrc. Your milage may vary, but I was pleased to find I didn’t need to make any changes, and, that I could get rid of one command from the script because Zsh defaults to a behaviour I had to explicitly opt in to with Bash.

TL;DR: environment variables (including PATH) and aliases work just the same in Zsh as they do in Bash, so if those are the only things you alter in your ~/.bashrc, then you can just copy it over to ~/.zshrc. But, if you alter Bash settings in your ~/.bashrc, you’ll need figure out the equivalent Zsh options and replace the relevant lines with the appropriate Zsh setopt or unsetopt Zsh commands.

Read more

Tagged with:

This post is part 1 of 6 in the series Bash to Zsh

During their 2019 World Wide Developers Conference (WWDC 2019) Apple announced that the default command shell for their next OS release (macOS Catalina) from the Bourne Again Shell (Bash) to the Z Shell (Zsh). Not only will Apple be switching the default in Catalina, they will be removing Bash completely in an as-yet unspecified future update. Apple’s advice is clear — make the switch now so you’re ready!

Never being one to try hold back the tide, I dove right in and made the switch within 5 minutes of reading about the announcement. This series will document my experience of making the change.

Read more

Tagged with:

This post is part 5 of 6 in the series Bash to Zsh

As I continue my move from Bash to Zsh at Apple’s strong suggestion I continue to bump into little differences that cause me minor problems. Today it was the fact that while Bash treats comments as comments even when they’re entered in an interactive shell, Zsh does not, at least not by default on MacOS.

TL;DRsetopt INTERACTIVE_COMMENTS

Read more

Tagged with:

This post is part 4 of 6 in the series Bash to Zsh

At Apple’s advice I’ve switched the login shell from Bash to Zsh on all my Macs. For the most part, what worked in Bash works in Zsh, but sometimes I do still want to get back to Bash to test something or to check something. You might imagine that simply typing bash from a Zsh prompt would get you a Bash shell, and you’d be right, sort of. When you just run the command bash you get a bare shell without the customisations that would have been applied when you opened a new Terminal window with Bash as your default shell. This will be immediately obvious because the prompt will be the basic bash-3.2$ as opposed to the hostname, current folder, and you’re username like you were used to.

The solution is really simple — pass the -l flag to signify that you want your new shell treated like a login shell, and hey presto, you’re back to Bash just like you remembered it 🙂

So, if you switch your Mac to Zsh, you get back to the Bash experience you had before with the following command:

bash -l

Tagged with:

This post is part 21 of 39 in the series Taming the Terminal

This is the third and final instalment on searching. In the first instalment we learned how to search for text within files and streams using egrep. In the second we learned to search for files based on all sorts of criteria with the find command. In this final instalment we’ll start by looking at one last feature of find, its a ability to execute commands on the files it finds. Then we’ll end by looking at an OS X-only alternative to find that makes use of the Spotlight search index to really speed up searches.

Read more

Tagged with:

This post is part 20 of 39 in the series Taming the Terminal

In the previous previous instalment we looked at using egrep to search for a particular piece of text in a stream or file. egrep is often a great tool for finding a file you are looking for, but only if the file is a plain text file, and only if you are searching for that file based on its content. What if you want to search for files based on other criteria, like the last time the file was edited, or the name of the file, or the size of the file, or the type of the file etc.? For that you need a different command, for that you need find.

Read more

Tagged with:

This post is part 19 of 39 in the series Taming the Terminal

In the previous two instalments (17 & 18) of this series we learned how to represent patters with regular expressions, or, to be more specific, with POSIX Extended Regular Expression (or EREs). We used the egrep command to test our regular expressions, but we didn’t discus the command itself in detail. Now that we understand regular expressions, it’s time to take a closer look at both egrep, and it’s older brother grep, both commands for filtering and searching text.

Read more

Tagged with:

This post is part 18 of 39 in the series Taming the Terminal

In the previous instalment we introduced the concept of Regular Expressions, and started to learn the POSIX ERE regular expression language, noting that POSIX ERE is a sub-set of the very commonly used Per Compatible Regular Expression (PCRE) language.

In this instalment we’ll learn more POSIX ERE syntax, and have a look at some examples of REs in GUI apps.

Read more

Tagged with:

This post is part 17 of 39 in the series Taming the Terminal

This instalment is the start of a series of instalments relating to searching from the command line. Searching is all about patterns, and that means getting to grips with Regular Expressions (also called RegExps, RegExes or REs for short). Regular Expressions are languages for representing patterns, and are used throughout IT, not just on the command line. While this series focuses on the Terminal, an understanding of regular expressions will be helpful in many other places, from programming languages to GUI apps like programming editors, search utilities or file re-namers. It’s going to take us two instalments to properly describe regular expressions, but when we’re done we’ll have gained a very useful skill.

Read more

Tagged with:

This post is part 16 of 39 in the series Taming the Terminal

In the previous instalment we introduced the concepts of streams, and looked at how every process has references to three streams as part of their environment – STDIN, STDOUT & STDERR. We went on to introduce the concept of operators that manipulate these streams, and we focused on the so-called ‘pipe’ operator which connects STDOUT in one process to STDIN in another, allowing commands to be chained together to perform more complex tasks. We mentioned the existence of operators for connecting streams to files, and the possibility of streams being merged together, but didn’t go into any detail. Well, that’s what we’ll be doing in this instalment.

Read more

Tagged with:

keep looking »