I have just recently improved my terminal setup after learning how to use Tmux. It gave me a way to move faster between projects and even kept my session saved after machine shutdowns. My goal here is to help you configure an environment that will be both beautiful and functional. Let's get to it.
Note: the following steps are done in Ubuntu. The same result can be achieved in MacOS with iTerm2 as the terminal.
When I worked with MacOS, I used iTerm2, but now on Linux I am using Guake as my default terminal. What I look for is to be able to open the command line in any monitor with a simple
CTRL + SPACE
shortcut.So if you're on Ubuntu, just install it with
apt
.sudo apt install guake
Choose your shortcut
Go to Preferences → Keyboard Shortcuts and choose your key to Toggle Guake Visibility.
Change your theme to Dracula
Dracula is one of the most famous themes out there. I use it both my terminal and VSCode. Guake already comes with it pre-installed, so go to Preferences → Appearance and choose Dracula as a Built-in scheme.
Other configs
You might also want to change the transparency and height of the window. Check out their documentation for more.
Now, let's install Z shell in Ubuntu.
sudo apt install zsh
For other platforms, please check this guide.
Set it as your default shell.
chsh -s $(which zsh)
You will have to logout for the changes to take effect.
Again, in Guake go to Preferences → Shell and set your default interpreter to
/usr/bin/zsh
. Restart it and you should see the message below.Choose option 0. We will be setting this up with Oh My Zsh.
Installing Oh My Zsh
Oh My Zsh is a framework to manage your Zsh configuration, themes, plugins, and much more.
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
After the successful installation, you should see the screen below.
You are now ready to install autocomplete and multiple plugins that will make your life easier. Check out the available plugins in the documentation.
I suggest you start with the following:
zsh-autosuggestions:
makes suggestions based on commands you have already made.zsh-syntax-highlighting:
enables highlighting of commands while they are typed.Clone both plugins to your OhMyZsh custom folder.
cd ~/.oh-my-zsh/custom/plugins
git clone https://github.com/zsh-users/zsh-autosuggestions.git
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
Now, edit your
~/.zshrc
file to include them.plugins=(
git
zsh-autosuggestions
zsh-syntax-highlighting
)
Restart your Zsh with
source ~/.zshrc
.Now, if you start typing, you will see the suggestions and can press the
right arrow key
to quickly autocomplete.Powerlevel10k is a theme for Zsh. It emphasizes speed, flexibility, and out-of-the-box experience.
Install the required fonts
Configure Guake by opening Preferences → Apperance. Then, uncheck "Use the system fixed width font" and select MesloLGS NF Regular. For more details check their guide here.
Clone the repository
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
Then, add powerlevel10k to
~/.zshrc
ZSH_THEME="powerlevel10k/powerlevel10k"
Restart Zsh with
source ~/.zshrc
and follow the configuration wizard.Choose your preferred style on the following screens.
Apply the changes to your
zshrc
and you're done.You will end up with a result like the one below.
In this last section, we will be installing Tmux with Dracula Theme.
sudo apt install tmux
For other platforms, check this guide.
Then run it.
tmux new
You will notice that we have lost the colors we had before. Let's bring them back with the next configs.
Install tpm to handle tmux plugins.
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
Edit
~/.tmux.conf
and put this at the bottom.# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin '[email protected]:user/plugin'
# set -g @plugin '[email protected]:user/plugin'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
Reload tmux environment
# type this in terminal if tmux is already running
tmux source ~/.tmux.conf
Now, let's install Dracula Theme as a tpm plugin. Add the following to your
~/.tmux.conf
file.set -g @plugin 'dracula/tmux'
# Set 256 colors
set -s default-terminal 'tmux-256color'
Press
<prefix> + I
(capital i) to install it. The default prefix is ctrl + b
.You can now quit tmux by typing
exit
and then create a new session with tmux new
. You should now have Powerlevel10k running with Tmux and Dracula Theme.As an extra, install the following plugins to save and restore your tmux sessions at any time.
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
And now you should be ready to go!
Quick commands:
prefix + %
and prefix + "
.prefix + x
.prefix + arrow
.prefix + c
.prefix + number
.prefix + ,
prefix + z
prefix + d
and reattach with tmux
.You can check out my configurations at:
Please, leave a comment telling me what you think about this setup and if you know other ways I can improve it. :)
Previously published at https://andrebrandao.me/articles/terminal-setup-with-zsh-tmux-dracula-theme/
Disclaimer: The author provides this code and software “AS IS”, without
warranty of any kind, express or implied, including but not limited to fitness for a particular purpose and non-infringement. In no event shall the
author be liable for any claim, damages or other liability in connection with the software or code provided here