My final shell setup with Fish shell and Tmux (Half 1)
I’ve not too long ago been requested to share my shell setup, which in case you ask me, that’s one of many highest ranges of reward you’ll be able to obtain as a software program developer ???? On this article, I’ll describe the setup I’ve been utilizing for the previous few years, and obtain related outcomes your self.
????️ The outcome
First, let’s take a look at what we’ll attempt to obtain by a screenshot I took final 12 months when exhibiting off to a senior co-worker of mine. Visually talking, nearly nothing modified since then, so let me simply be lazy for some time and re-use this overly annotated screenshot.
I feel some folks go for very minimalist shell setups, and I suppose you might say that I favor the precise reverse of minimalist on this regard ???? The screenshot above is lacking two vital components, which might be the exit code of beforehand executed command and presence of background processes – to not fear, these components usually are not omitted, simply hidden in case no fascinating info is accessible to point out (final course of terminated efficiently/no background processes are operating respectively).
???? Conditions
To attain related outcomes, I imagine you’ll want two items of puzzle that I’ll not cowl intimately on this article:
- Succesful terminal emulator (macOS’
Terminal.app
doesn’t qualify) – I’ve been residing within the iTerm2 land since I migrated to macOS, all the time configured the superior Solarized Dark colour theme; - Nerd-patched font for all of the particular glyphs that our shell will present us – both patch a font of your liking your self or go along with one of many pre-patched fonts; common decisions embody FiraCode, Hack, Inconsolata, Iosevka and others.
???????? All of it begins within the shell…
After utilizing bash
for a few years and zsh
for a lot of extra years, I switched to fish
shell a number of years in the past. Whereas zsh
is a positive shell, I felt that fish
could be extra user-friendly and simpler to customise – however I acknowledge that this doesn’t come with out drawbacks, specifically that fish
shell doesn’t respect the normal POSIX syntax so that you’ll must positively alter a few of your habits. Let’s first set up fish
shell after which I’ll share a number of tips to get extra accustomed to fish
shell.
brew set up fish
echo /usr/native/bin/fish | sudo tee -a /and so on/shells
chsh -s /usr/native/bin/fish $(whoami)
Say “bye-bye” to bash
/zsh
as a result of the subsequent time you open a terminal, you ought to be welcomed by a pleasant interactive shell, like so:
Subsequent, set up Oh My Fish, which is actually a bundle supervisor for Fish shell, together with some important plugins and themes:
curl -L https://get.oh-my.fish | fish
omf set up bobthefish # Theme
omf set up aws # AWS integration & command completion
omf set up bass # Permits operating closely Bash-dependant utilities, like nvm
omf set up brew # Combine Homebrew paths
omf set up colored-man-pages
omf set up export # Deliver again Bash-like export command
omf set up https://github.com/jhillyerd/plugin-git
omf set up osx # Finder/macOS integration and utilities
omf set up wifi-password
omf set up z # Autojump implementation
For extra details about what these do, examine the package list – for instance, wifi-password
exhibits you the present WiFi password – not one thing you want every single day, however whenever you want it, it’s very good to have; z
means that you can rapidly soar throughout usually visited directories simply by typing a part of their names; and the git
plugin (documentation available here) offers you extra git
aliases and abbreviations than you might ever bear in mind.
You’ll discover that even with the bobthefish
theme put in and robotically activated, your shell immediate nonetheless appears approach completely different from the primary screenshot I offered – so let’s configure the shell and immediate. Listed under is the content material of the ~/.config/fish/config.fish
file I presently use, however be happy to regulate it to your coronary heart’s content material:
set -gx COLORTERM truecolor
set -gx EDITOR nvim
set -gx LANG cs_CZ.UTF-8 # Modify this to your language!
set -gx LC_ALL cs_CZ.UTF-8 # Modify this to your locale!
set -gx VIRTUAL_ENV_DISABLE_PROMPT true
set -gx GOPATH $HOME/go
set -x PATH $GOPATH/bin $HOME/.composer/vendor/bin $HOME/Library/Python/3.7/bin $PATH
set -gx HOMEBREW_AUTO_UPDATE_SECS 86400
set -gx DOCKER_BUILDKIT 1
set -gx COMPOSE_DOCKER_CLI_BUILD 1
set -g fish_key_bindings fish_vi_key_bindings
set -g fish_bind_mode insert
# Title choices
set -g theme_title_display_process sure
set -g theme_title_display_path sure
set -g theme_title_display_user sure
set -g theme_title_use_abbreviated_path sure
# Immediate choices
set -g theme_display_ruby sure
set -g theme_display_virtualenv sure
set -g theme_display_vagrant no
set -g theme_display_vi sure
set -g theme_display_k8s_context no # sure
set -g theme_display_user sure
set -g theme_display_hostname sure
set -g theme_show_exit_status sure
set -g theme_git_worktree_support no
set -g theme_display_git sure
set -g theme_display_git_dirty sure
set -g theme_display_git_untracked sure
set -g theme_display_git_ahead_verbose sure
set -g theme_display_git_dirty_verbose sure
set -g theme_display_git_master_branch sure
set -g theme_display_date sure
set -g theme_display_cmd_duration sure
set -g theme_powerline_fonts sure
set -g theme_nerd_fonts sure
set -g theme_color_scheme solarized-dark
bind -M insert cg neglect
if which asdf > /dev/null; standing --is-interactive; and supply (brew --prefix asdf)/asdf.fish; finish
if which direnv > /dev/null; direnv hook fish | supply; finish
if which goenv > /dev/null; standing --is-interactive; and supply (goenv init -|psub); finish
if which rbenv > /dev/null; standing --is-interactive; and supply (rbenv init -|psub); finish
if which swiftenv > /dev/null; standing --is-interactive; and supply (swiftenv init -|psub); finish
Line 42 binds a neglect
perform to the important thing mixture of Ctrl-G
, so let’s create the neglect
perform proper now by pasting the next into ~/.config/fish/features/neglect.fish
:
perform neglect
set -l cmd (commandline | string accumulate)
printf "nDo you wish to neglect '%s'? [Y/n]n" $cmd
swap (learn | tr A-Z a-z)
case n no
commandline -f repaint
return
case y sure ''
historical past delete --exact --case-sensitive -- $cmd
commandline ""
commandline -f repaint
finish
finish
What this does is means that you can simply take away command from shell’s historical past, for instance in case you typed delicate info or made a typo in a command that you just don’t wish to get reminded of sooner or later. Activate it by going up the historical past with the up arrow key ⬆️⌨️ till you hit the command you want to neglect, then activate the perform by urgent Ctrl-G
. Talking of fish
features, right here’s another you would possibly discover helpful – get a random Git-related tip as spoken with a random pony anytime you open a brand new shell! First, let’s set up the dependencies:
brew set up ponysay
npm set up -g git-tip
Then put the next textual content into ~/.config/fish/features/fish_greeting.fish
:
perform fish_greeting
git-tip | ponysay
finish
In case you adopted the information correctly (and if I haven’t missed something), your terminal ought to now look pretty much like mine!
???? Fish survival information
As I discussed originally of the article, Fish is usually completely different. I hope that this little desk will enable you overcome probably the most issues you might face:
bash command |
fish equal |
Notes |
---|---|---|
true && true |
true; and true |
|
true || false |
true; or false |
|
echo "Date: $(date)" |
echo "Date: "(date) |
|
export A=b |
set -gx A b |
You possibly can preserve utilizing export with the OMF plugin we put in |
echo "A=${A}" |
echo "A="$A |
|
for i in $(seq 10); echo $i; executed |
for i in (seq 10); echo $i; finish |
|
Ctrl-R for historical past search |
Kind search time period, then press ⬆️ key | Or omit search time period for linear historical past shopping |
For extra in-depth survival information, remember to examine the official documentation.
And since this text is getting fairly lengthy, let’s save the Tmux half for subsequent time!