Skip to main content

Essential Environment Setup

iTerm

Let's start with installing iTerm.

Please visit https://iterm2.com then download and install it.

Install color themes

Visit https://iterm2colorschemes.com and download the zip or tar.gz and extract it. Follow the installation instruction.

e.g.)

iTerm color themes Example

Homebrew

Homebrew is a package manager for macOS (and Linux).

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

zsh (Z shell)

macOS's default shell is z-shell, so you don't need to install it.

To check the default shell

echo $SHELL

You should see something like

/bin/zsh

Oh My Zsh

Oh my zsh is an open source framework for managing Zsh configuration.

Install Oh My Zsh.

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Font for Coding

brew tap homebrew/cask-fonts

FiraCode

brew install --cask font-fira-code

For nerd font,

brew install --cask font-fira-code-nerd-font 

Fira Code Sample

Microsoft Cascadia Code

brew install font-cascadia-code-pl

For nerd font,

brew install --cask font-caskaydia-cove-nerd-font 

Cascadia Code Sample

JetBrains Mono

brew install font-jetbrains-mono
brew install font-jetbrains-mono-nerd-font

JetBrains Mono Sample

Dot Files (WIP)

You can keep all aliases, environment variables and functions in ~/.zshrc but as the file gets bigger, it would be hard to maintain it. So it would be a good idea to put them in to multiple files depending on their relevance.

mkdir -p ~/.my-dot-file
echo 'if [ -f ~/.my-dot-file/.all_my_rc ]; then
. ~/.my-dot-file/.all_my_rc
fi' >> ~/.zshrc

Now you can have multiple .some_rc files in ~/.my-dot-file and load them in the ~/.my-dot-file/.all_my_rc so that ~/.zshrc can load them all.

TBD

Oh My Posh

Oh My Posh is a prompt theme engine for any shell.

brew install jandedobbeleer/oh-my-posh/oh-my-posh 

To be added...

Other Tools

git

brew install git 

exa

exa is a modern replacement for ls written in Rust.

brew install exa 

Once installed, you can replace ls with exa by adding aliases like.

if type exa >/dev/null 2>&1; then
alias ls0='command ls -G'
alias ll0='ls0 -l'
alias l0='ls0 -al'
alias ls='exa'
alias ll='ls --color-scale -lh'
alias l='ls --color-scale -lah'
else
alias ls='ls -G'
fi

Now you ls is exa. ls -l can be done by ll and ls -a is just l.

You can still use ls by running ls0 (but why?! 🤔)

curl

brew install curl 

HTTPie

HTTPie is a simple and intuitive http client CLI tool similar to curl. httpie now has a desktop app as well.

brew install httpie 

It installs http and https.

Try the following command to test,

https httpie.io/hello 

wget

brew install wget 

fd

fd is an alternative to find.

brew install fd 

grep

macOS alreadys has grep but if you want to use GNU grep, you can run the following command to install it.

brew install grep 

htop

htop is a cross-platform interactive process viewer.

brew install htop 

bat

bat (🦇) is an alternative to cat (🐈) with syntax highlighting and Git integration.

brew install bat 

Let's compare bat with cat.

First cat,

cat

Now, bat,

bat

delta

delta is a syntax-highlighting pager for git.

brew install git-delta 

Once installed, add delta to ~/.gitconfig

[core]
pager = delta

For more about delta configuration, please visit the delta user manual.

FYI, this is what I have in my ~/.gitconfig.

[core]
pager = delta

[interactive]
diffFilter = delta --color-only

[delta]
navigate = true
side-by-side = true
features = line-numbers decorations
syntax-theme = Monokai Extended Bright
plus-style = syntax "#003800"
minus-style = syntax "#3f0001"

[delta "decorations"]
commit-decoration-style = bold yellow box ul
file-style = bold yellow ul
file-decoration-style = none
hunk-header-decoration-style = cyan box ul

[delta "line-numbers"]
line-numbers-left-style = cyan
line-numbers-right-style = cyan
line-numbers-minus-style = 124
line-numbers-plus-style = 28

Now the result of git diff may look like this.

delta-example

procs

procs is a modern alternative to ps written in Rust.

brew install procs 

e.g.)

$ procs
PID:▲ User │ TTY CPU MEM CPU Time │ Command
[%] [%]
1 root │ 0.0 0.3 00:06:14 │ /lib/systemd/systemd --system --deserialize 20
2 root │ 0.0 0.0 00:00:05 │ kthreadd
4 root │ 0.0 0.0 00:00:00 │ kworker/0:0H
6 root │ 0.0 0.0 00:00:00 │ mm_percpu_wq
7 root │ 0.0 0.0 00:00:42 │ ksoftirqd/0
8 root │ 0.0 0.0 00:19:13 │ rcu_sched
9 root │ 0.0 0.0 00:00:00 │ rcu_bh
10 root │ 0.0 0.0 00:00:00 │ migration/0
11 root │ 0.0 0.0 00:01:18 │ watchdog/0
12 root │ 0.0 0.0 00:00:00 │ cpuhp/0
13 root │ 0.0 0.0 00:00:00 │ kdevtmpfs
14 root │ 0.0 0.0 00:00:00 │ netns
15 root │ 0.0 0.0 00:00:00 │ rcu_tasks_kthre
16 root │ 0.0 0.0 00:00:00 │ kauditd
17 root │ 0.0 0.0 00:02:53 │ khungtaskd
18 root │ 0.0 0.0 00:00:00 │ oom_reaper
19 root │ 0.0 0.0 00:00:00 │ writeback
20 root │ 0.0 0.0 00:00:00 │ kcompactd0
21 root │ 0.0 0.0 00:00:00 │ ksmd
22 root │ 0.0 0.0 00:00:00 │ khugepaged
:

dust

dust is more intuitive du - display disk usage statistics

brew install dust 

e.g.)

$ dust
4.0K ┌── blah-b1a.txt│ ████████ │ 17%
4.0K ┌─┴ b1 │ ████████ │ 17%
4.0K ┌─┴ b │ ████████ │ 17%
0B │ ┌── c2 │ ░░░░░░░░░░░░░░█ │ 0%
4.0K │ ├── blah-c.txt │ ░░░░░░░████████ │ 17%
4.0K │ │ ┌── blah-c1a.txt│ ░░░░░░░████████ │ 17%
4.0K │ ├─┴ c1 │ ░░░░░░░████████ │ 17%
8.0K ├─┴ c │ ███████████████ │ 33%
0B │ ┌── a2 │ ░░░░░░░░░░░░░░░░░░░░░░█ │ 0%
0B │ ├── a3 │ ░░░░░░░░░░░░░░░░░░░░░░█ │ 0%
4.0K │ ├── blah-a.txt │ ░░░░░░░░░░░░░░░████████ │ 17%
4.0K │ │ ┌── blah-a1a.txt│ ░░░░░░░░▒▒▒▒▒▒▒████████ │ 17%
4.0K │ │ ├── blah-a1b.txt│ ░░░░░░░░▒▒▒▒▒▒▒████████ │ 17%
8.0K │ ├─┴ a1 │ ░░░░░░░░███████████████ │ 33%
12K ├─┴ a │ ███████████████████████ │ 50%
24K ┌─┴ . │████████████████████████████████████████████ │ 100%

fzf

fzf is a general-purpose command-line fuzzy finder.

brew install fzf
  • Optional
    # To install useful key bindings and fuzzy completion:
    $(brew --prefix)/opt/fzf/install

e.g.)

$ fzf
  b/b1/blah-b1a.txt
c/c1/blah-c1a.txt
c/blah-c.txt
a/a1/blah-a1a.txt
a/a1/blah-a1b.txt
> a/blah-a.txt
6/6
>
  c/c1/blah-c1a.txt
> c/blah-c.txt
2/6
> c
> c/c1/blah-c1a.txt
1/6
> c1

tokei

tokei is a tool to get statistics of a project source code.

brew install tokei

e.g.)

$ tokei 
===============================================================================
Language Files Lines Code Comments Blanks
===============================================================================
CSS 2 84 58 13 13
JavaScript 4 277 267 0 10
JSON 4 11199 11199 0 0
Scala 150 74098 58383 952 14763
YAML 1 2 2 0 0
-------------------------------------------------------------------------------
Markdown 46 2725 0 1965 760
|- Scala 24 7733 6346 47 1340
(Total) 10458 6346 2012 2100
===============================================================================
Total 207 88385 69909 2930 15546
===============================================================================
$ tokei --exclude "*.json" 
===============================================================================
Language Files Lines Code Comments Blanks
===============================================================================
CSS 2 84 58 13 13
JavaScript 4 277 267 0 10
Scala 150 74098 58383 952 14763
YAML 1 2 2 0 0
-------------------------------------------------------------------------------
Markdown 46 2725 0 1965 760
|- Scala 24 7733 6346 47 1340
(Total) 10458 6346 2012 2100
===============================================================================
Total 203 77186 58710 2930 15546
===============================================================================
$ tokei --exclude "*.json" --exclude "website"
===============================================================================
Language Files Lines Code Comments Blanks
===============================================================================
Scala 202 78295 62349 1160 14786
YAML 1 6 5 0 1
-------------------------------------------------------------------------------
Markdown 67 4209 0 3046 1163
|- Scala 40 10970 8954 83 1933
(Total) 15179 8954 3129 3096
===============================================================================
Total 270 82510 62354 4206 15950
===============================================================================
$ tokei modules
===============================================================================
Language Files Lines Code Comments Blanks
===============================================================================
Scala 201 78282 62339 1160 14783
===============================================================================
Total 201 78282 62339 1160 14783
===============================================================================
$ tokei website
===============================================================================
Language Files Lines Code Comments Blanks
===============================================================================
CSS 2 94 60 19 15
JavaScript 5 506 427 51 28
JSON 6 21425 21425 0 0
===============================================================================
Total 13 22025 21912 70 43
===============================================================================
tokei docs
===============================================================================
Language Files Lines Code Comments Blanks
===============================================================================
JSON 7 42 42 0 0
-------------------------------------------------------------------------------
Markdown 35 3832 0 2740 1092
|- Scala 33 10831 8848 78 1905
(Total) 14663 8848 2818 2997
===============================================================================
Total 42 3874 42 2740 1092
===============================================================================

bottom

bottom is a customizable cross-platform graphical process/system monitor for the terminal. It is like htop with more graphical representation.

brew install bottom 

NOTE: to run bottom, the command is not bottom but btm.

$ btm

bottom example

bandwhich

bandwhich is a utility for displaying current network utilization.

brew install bandwhich 
# If bandwhich doesn't work,
$ sudo bandwhich
 Total Up / Down: 1.66KiBps / 910Bps
┌Utilization by process name─────────────────────┐┌Utilization by remote address──────────────────┐
│Process Connections Up / Down ││Remote Address Up / Down │
│ ││ │
│Abc[...]xyz 5 1.56KiBps / 231Bps ││syd1[..]net. 1.51KiBps / 181Bps │
│Someapp 6 102Bps / 462Bps ││PC-1. 0Bps / 576Bps │
<UNKNOWN> 1 0Bps / 216Bps ││PC-2. 0Bps / 102Bps │
│ ││192.168.123.255 51Bps / 0Bps │
│ ││255.255.255.255 51Bps / 0Bps │
│ ││syd1[..]net. 16Bps / 13Bps │
│ ││syd6[..]net. 16Bps / 13Bps │
│ ││ec2-[..]com. 4Bps / 6Bps │
│ ││cdn-[..]com. 4Bps / 6Bps │
│ ││cdn-[..]com. 4Bps / 6Bps │
│ ││1.2.3.200 4Bps / 4Bps │
│ ││ │
└────────────────────────────────────────────────┘└───────────────────────────────────────────────┘
┌Utilization by connection────────────────────────────────────────────────────────────────────────┐
│Connection Process Up / Down │
│ │
<en0>:49269 => syd15s20-in-f14.1e100.net.:443 (udp) Abc[...]xyz 1.51KiBps / 181Bps │
<en0>:12345 => PC-1.:12345 (udp) Someapp 0Bps / 315Bps │
<en0>:54915 => PC-1.:54915 (udp) <UNKNOWN> 0Bps / 216Bps │
<en0>:12345 => 255.255.255.255:12345 (udp) Someapp 51Bps / 0Bps │
<en0>:12345 => 192.168.2.255:12345 (udp) Someapp 51Bps / 0Bps │
<lo0>:12345 => PC-2.:12345 (udp) Someapp 0Bps / 51Bps │
<lo0>:12345 => PC-2.:12345 (udp) Someapp 0Bps / 51Bps │
<en0>:12345 => PC-1.:12345 (udp) Someapp 0Bps / 45Bps │
<en0>:51627 => syd12345-in-f14.1e100.net.:443 (udp) Abc[...]xyz 16Bps / 13Bps │
<en0>:62557 => syd67890-in-f10.1e100.net.:443 (udp) Abc[...]xyz 16Bps / 13Bps │
<en0>:56299 => cdn-111-222-333-444.github.com.:443 (tcp) Abc[...]xyz 4Bps / 6Bps │
<en0>:56312 => ec2-12-345-6[...]te.amazonaws.com.:443 (tcp) Abc[...]xyz 4Bps / 6Bps │
└─────────────────────────────────────────────────────────────────────────────────────────────────┘
Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).

grex

grex is a tool to simplify the task of creating regular expressions.

brew install grex 

e.g.)

$ grex a-111 a-222 a-333
^a\-(?:111|222|333)$
$ grex -d a-111 a-222 a-333
^a\-\d\d\d$
$ grex -d a-111 a-222 a-333 b-111
^[ab]\-\d\d\d$
$ grex -d a-111 a-222 a-333 b-111 c-000
^[a-c]\-\d\d\d$
$ grex -d a-111 a-222 a-333 b-111 c-000 d-1234
^(?:d\-\d|[a-c]\-)\d\d\d$
$ grex -d a-111 a-2220 a-333 b-111 c-000 d-1234
^(?:a\-\d\d\d(?:\d)?|d\-\d\d\d\d|[bc]\-\d\d\d)$
$ grex -d a-111 a-2220 a-333 b-111 c-000 d-111 d-1234
^(?:[ad]\-\d\d\d(?:\d)?|[bc]\-\d\d\d)$
$ grex -w -d a-111 a-2220 a-333 b-111 c-000 d-111 d-1234
^\w\-\d\d\d(?:\d)?$
$ grex -w -d a-111 a-2220 a-333 b-111 b-1111 c-000 c-0000 d-111 d-1234
^\w\-\d\d\d(?:\d)?$
$ grex -w -d a-111 a-2220 a-333 b-111 b-1111 c-000 c-0000 d-111 d-12345
^\w\-\d\d\d(?:\d(?:\d)?)?$
$ grex -rwd a-111 a-2220 a-333 b-111 b-1111 c-000 c-0000 d-111 d-12345
^\w\-\d{3,5}$

$ grex -crwd a-111 a-2220 a-333 b-111 b-1111 c-000 c-0000 d-111 d-12345


^\w-\d{3,5}$

jq

jq is a lightweight and flexible command-line JSON processor.

brew install jq 

mcfly

brew install mcfly 

TBD