Neovim + Tmux + Zsh + Lazygit

We discovered that Neovim could be a powerful IDE with NvChad. It was great. I already set Neovim as my primary text editor. It could increase our productivity. But, that was not enough. You should try this combo.

Tmux

Tmux

Tmux can have multiple sessions, windows, and panes. We can have them without making our computers heavy because they all run on the terminal.

I rarely use sessions and panels. Mostly windows. For example, here are my windows when I work for a library:

  1. zsh. The default window. Maybe to run apps or Dockers or view logs.
  2. go. Running Neovim to code the library in Go.
  3. nodejs. Running Neovim to code the library in (TypeScript) NodeJS.
  4. php. Running Neovim to code the library in PHP.
  5. lazygit. Running Lazygit to see changes for the active directory.

For information, the window start at 0. Run tmux on the terminal to start Tmux. Ctrl / Control + b to start a command. Here are basic usages.

Key Description
c Create a window
, Rename the window
0 to 9 Switch the window
% Split the window horizontally
" Split the window vertically
← / ↑ / → / ↓ Switch the pane
d Detach the session

You can do other stuff while the session is detached such as SSH to a server, configure some files, etc. Run tmux -a to get back to the last session. You can see Tmux Cheat Sheet for other commands.

Installing Tmux is quite easy. But, maybe you don't like the default UI. You can theme it with the Catppuccin. It is not only a theme. It has some useful modules such as showing Git active branch, battery, weather, and calendar. But, you need TPM (Tmux Plugin Manager) to install Tmux plugins to activate those modules.

I made it easy to configure Tmux with Catppuccin by providing my ~/.tmux.conf.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# List of plugins
set -g @plugin 'catppuccin/tmux#latest'
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-battery'
set -g @plugin 'tmux-plugins/tmux-cpu'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'xamut/tmux-weather'

set -g @catppuccin_window_right_separator "█ "
set -g @catppuccin_window_number_position "right"
set -g @catppuccin_window_middle_separator " | "
set -g @catppuccin_window_default_fill "none"
set -g @catppuccin_window_current_fill "all"
set -g @catppuccin_window_default_text "#W"
set -g @catppuccin_window_current_text "#W"
set -g @catppuccin_status_modules_right "session gitmux battery weather date_time"
set -g @catppuccin_status_left_separator "█"
set -g @catppuccin_status_right_separator "█"
set -g @catppuccin_date_time_text "%Y-%m-%d %H:%M:%S"

set -g status-position top
set-option -g @tmux-weather-location "Tangerang"
# set-option -g default-shell /usr/bin/zsh
set-option -g default-terminal 'screen-256color'
set-option -sg escape-time 10
set-option -g focus-events on
set-option -a terminal-features 'screen-256color:RGB'

# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'github_username/plugin_name#branch'
# set -g @plugin 'git@github.com:user/plugin'
# set -g @plugin 'git@bitbucket.com:user/plugin'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

Make sure you have already installed the Tmux with TPM. Then, run this command to install them, ~/.tmux/plugins/tpm/bin/install_plugins.

The script above worked on any OS. On line 23, you might notice I commented on a line. You can activate it to replace your default Bash shell with Zsh, only on Tmux. Remember, that only works if your default shell is Bash and you already installed Zsh.

You can try other awesome Tmux plugins from Awesome Tmux.

Zsh

Zsh (Z shell) is an extended or improved version of Bash. It is a default shell for macOS. There are two things I like from Zsh:

  1. It doesn't show a full path like Bash.
  2. It shows Git active branch and a sign for tracked files.

It might not show Git stuff by default. Then, we need to install Oh My Zsh. It brought a theme for your Zsh too. Remember to install Zsh first.

You can set your theme to the environment variable, ZSH_THEME. But I think the default, robbyrussell, is fine.

Lazygit

I always use Git commands without UI, even to see Git logs. But, when I need UI, I use Lazygit.

The only Git UI that works on the terminal I know is Lazygit. Git UI is important for reviewing changes, especially a lot of changes. Run lazygit to launch Lazygit. Here are basic usages.

Key Description
Tab Go to the next tab
Shift + Tab Go to the previous tab
j Go to the next item
k Go to the previous item
p Pull
Shift + p Push
Enter / Return Enter the item
Esc Escape from the item
q Quit

Related Articles

Comments

comments powered by Disqus