Mac Terminal Power User
This article details my personnal configuration. Feel free to suggest improvements in the comments! You can get my configuration files at the end of this article.
The videos of my terminal are recorded with Asciinema. You can pause a video and copy-paste the texts!
The vast majority of things here would work for Linux.
- Terminal: iTerm2
- Shell: ZSH
- Command-line Text Editor:
- My conf files
Terminal app is not so bad. But you could have a better terminal:
iTerm2. You can find the pros and cons here but basically it’s more customizable.
For instance you don’t have to stick with the few (ugly) default themes. The
iTerm community has designed hundreds! Check them out: https://github.com/mbadolato/iTerm2-Color-Schemes. To install them:
$ git clone email@example.com:mbadolato/iTerm2-Color-Schemes.git wherever you want then in iTerm2 go to
preferences > profiles > colors > color preset > import... then chose the cloned folder and its
shemes folder. You should see a buch of files like
deep.itermcolors: just select them all and click on
open. There you go! I use
Enable Word Jump
option + → sends the cursor at the end of the current word. This is not enabled by default in
iTerm. To enable it:
preferences > profiles > keys > load preset > Natural Text Editing
The shell on your Mac is most probably an old
bash. You got used to it. You don’t even know how much struggle you could avoid by using an other shell and extensions!
I recomment you switch to
zsh in lieu of
bash and use the
oh-my-zsh extensions to get cool features as:
- autocompletion on path
$ cd dthen hitting
tabwould let you choose between
- using only
enteryou’ll get around your computer much quicker!
- no case-sensitivity
- using only
ztracks all the locations you go to and ranks them (roughly) by frequency. So if you often go to
~/github/vict0rsch/vict0rsh.github.io/, then from any location
$ z iowould get you there!
- cool themes! you can colorize your shell to emphasize information, show the current status of a
gitrepo (info like there are files are to be added, modifications not committed or commits not pushed)
- see which version of
pythonand which virtual env is currently active etc.
- see which version of
And even more cool stuff! Here is a demo of what you could get in a few minutes:
Notice how the command prompt changes, showing the git branch (
source), the git status (files to track, changes to commit and commits to push with
⇡), the current python version and the time I spent in python! (
gst stands for
git status and
git push, these are part of the
git plugin in
Then in your
.zshrc configure the theme:
You’ll need to activate the compatible fonts so in the
iTerm preferences go to
preferences > profiles > text there change the font to a powerline-compatible font (use the
powerline key-word in the top right search box). Then verify that “use a different font for non-ASCII characters” is NOT checked.
Make ZSH suggest commands with zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions then we’ll add it to the plugin list in the next section
_interchangeable for ZSH’s completion
plugins=(git, z, osx, sudo, brew, dirhistory, zsh-autosuggestions)Check the available plugins in Oh-my-zsh’s wiki
SPACESHIP_PROMPT_ORDER=(time, user, dir, host, git, aws, venv, pyenv, exec_time, line_sep, battery, jobs, exit_code, char)to get rid of things I do not use, see more in the docs
If you’re going to use
gsort from the
fs alias, do install
brew install coreutils
Command-line Text Editor:
“Micro is a terminal-based text editor that aims to be easy to use and intuitive, while also taking advantage of the full capabilities of modern terminals.” (https://github.com/zyedidia/micro)
It has full mouse support and usual shortcuts (with control):
^ + c to copy,
^ + v to paste etc.
Also, syntax highlighting!
brew install micro
I manage Python versions with
pyenv. Great advantage is the variety of versions at the tip of your fingers and their hierarchical management : you can set a
global version, a bit like a default, a
local wich may vary per folder or a
shell version, defined once per shell via an environment variable.
With these, adding a
.env file in the folder that should use the
virtualenv will automatically start it:
autoenv will execute whatever is written in this file so
echo "source ./myenv/bin/activate" > .env will do the trick! You can also add environment variables in this
A few lines should be added to your
.zshrc for pyenv and autoenv to work correctly:
I use Visual Code as it is pretty complete yet lightweight.
git source control is very well embedded in the editor, there are plenty of extensions and everything is customizable. I know also a lot of people using Pycharm.
I also use Visual Code for Web Development (React, Markdown for this blog, Flask).
Tmux is a way to run proccesses which do not depend on your shell being active. So if you close the terminal, the process will continue. If you work remotely and the SSH connection is broken the remote process will not stop. Then you just need to grab it back!
Tmux has sessions which have windows (a bit like the terminal’s tabs) and windows can be split into panes.
tmux new -s test starts a session called
^f c creates a new window in the session,
^f , renames the current window
shift + arrow navigates through windows
^f : opens tmux’s console (
kill-session could be useful for instance or
^f v splits the current window vertically into panes and
^f arrow navigates through the panes. If youy close the terminal and open a new one,
tmux a -t test to grab it back.
My conf files
These files should lie in your