WHELM Mac OS
Get the shell you deserve!
OSX by default comes with Python 2.7 installed, so we're going to update to the latest version of Python using brew. Then, we're going to deploy the newest version of git and vim and install. Whelm gives you a simple 1-9 scale to rate your under/over-whelmedness, or for those places that whelmed you just right, there's a spot right in the middle.
Join the DZone community and get the full member experience.
Join For FreeIf you're an active Mac user that spends a good amount of time using shell, you may have noticed that the OSX Shell by default is bear bone and not very productive to use on a daily bases.
The question is, how we can make OSX shell more productive?
Getting Started
Install/Deploy iTerm2
iTerm2 is a replacement for Terminal and the successor to iTerm that brings multiple new features and optimizations that can make users more efficient.
We can iTerm2 download from the official Web Site.
iTerm2 provides features, including Split Panes, Search, Autocomplete, Split Panes, Instant Replay, etc. You can read more on their official Documentation Page.
You may also like: Implement a Command-Line Shell by Using Command Dispatcher in Python.
Install Xcode
Just running below command in the iTer2 will install Xcode.
Deploy Homebrew
Homebrew is the most used package manager for Apple macOS
Installation is a straight forward process. Simply run the following command in iTerm2.
Once we have Homebrew installed, we can update it.
OSX by default comes with Python 2.7 installed, so we're going to update to the latest version of Python using brew. Then, we're going to deploy the newest version of git and vim and install neovim as a potential replacement for vim. In addition, we will install a few more useful packages that come into the light later
As for Python, we can use pip to install to add any other packages/modules we may need.
Now, let's make our shell shine.
Add the following lines to your ~/.bash_profile
that will execute ~/.bashrc
during the terminal launch.
We can now make our bash prompt more colorful and useful by adding bash_completion
. In the ~/.bashrc
file, add the following code.
Now, we can configure the rest of bash (e.g. history aliases some color for man pages and nice color output for less and cat commands).
Add below lines to your ~/.bashrc
file
Example for ~/.vimrc
:
Let's enhance our command history; instead of cycling with up and down arrow keys through the entire history of the commands, you can type a command and cycle only for the latest history of the SYNOPSIS Ex. ls-a, ls -la, ls -la / ls -la /etc. Once you type ls, you can navigate through past commands you used.
Create a file in the home directory .inputrc
and add the following entries
Add below entry to ~/.bashrc
to import settings from ~/.inputrc
.
If you are a git user and use git CLI from the shell, it is nice to know what branch you are in without typing git branch
.
Download both files from following links into your home directory ~/
.
Then add the following lines into ~/.bashrc
.
Another useful tool to keep in mind is tmux.
Tmux is a terminal multiplexer for Unix-like operating systems. It allows multiple terminal sessions to be accessed simultaneously in a single window. It is useful for running more than one command line program at the same time. It can also be used to detach processes from their controlling terminals, allowing SSH sessions to remain active without being visible.
Install tmux.
Below is the configuration file used to configure tmux~/.tmux.conf
.
We change activition key binding for tmux from default Ctrl+b to Ctrl+a similar to screen.
Now that we configure nice-looking bash shell and terminal and learn how to take advantage of the added options we can move to a more advanced terminal and maybe even try to replace bash with more modern-looking shell FISH.
FISH, the friendly interactive shell, is a Unix shell that attempts to be more interactive and user-friendly.
Let's start by installing the FISH shell and a few add-ons like theme manager, oh-my-fish, that can male our FISH fly.
In the above example, we install FISH and oh-my-fish and deployed 'bobthefish' as a theme.
To make the FISH look even better, let's install powerline and fonts.
To make the FISH shell default when you start terminal usechsh
where you can replace bash with theFISH path
Do not forget to change fonts for iTerm2 to add newly installed fonts.
In Preferences../Profile/Text
You can add an additional configuration option for oh my FISH by editing and adding below lines to ~/.config/fish/config.fish
.
For tmux to start with FISH, you can add below two lines to the beginning of the ~/.tmux.conf
.
To add aliases you can add to ~/.config/fish/functions/
.
Examples you can find at https://github.com/mudrii/.files/tree/master/HWD_Mac/.config/fish/functions.
Your terminal should look much better with FISH and tmux.
We are not done yet; let's make vim look nice with our shell theme and functionality.
Mac Os Mojave
The first step is to install vim-plug, as the vim plugin manager, where can manage, install, and uninstall all needed plugins for vim.
Edit your ~/.vimrc
config file for vim and add the following lines.
Open vim and run PlugInstall
. This will install all plugins defined in ~/.vimrc
.
The rest of ~/.vimrc
(with some neat configuration options) can be found here.
Whelm Mac Os Download
With a few more useful apps, you can make use of are ranger as a file-manager in the shell terminal, bat as a replacement for cat, htop console process viewer manager, fdas areplacement for find, and p7zp advance archiver.
All configuration files used in this article you can find here.
Further Reading
- Functions in Shell Script.
- 5 Courses to Learn Linux Shell Scripting in 2019.
- JShell: Finally, an Official Shell in Java 9.
Mac Os Catalina
Published at DZone with permission of Ion Mudreac. See the original article here.
Whelm Mac Os Catalina
Opinions expressed by DZone contributors are their own.