Vim + Tmux For Hackers

Tmux + Vim for Hackers :)

As hackers, we spend most of our time working in the terminal. Green and dark screens are everywhere—that’s what makes us hackers! Vim is one of the greatest tools ever (after Git). Moving around without touching your mouse or even taking your hands off the keyboard is amazing. It’s like typing something, but actually, you’re navigating like a real hacker.

I’m not here to teach you how to use Vim or how to install it (even though it comes pre-installed on most Linux distros and macOS). Instead, I want to show you how combining Vim motions with Tmux will give you the ultimate terminal power. You’ll be more productive, innovative, and able to move seamlessly from one terminal window to another, split them into tabs, or open new windows like a pro.

First, make sure:

  • You have Vim installed.
  • You have Tmux installed.

You should also install `oh-my-tmux`, which is amazing for setting up Tmux easily.

This is my setup for tmux (config) : 

go to my .tmux repo and read the Readme.md file follow the setup to set up everything.

I assume you’ve already configured tmux (the config file should be in /home/USER/.tmux.conf).

Once everything is set up, open your favorite terminal and run:

$ tmux

This will start a new tmux session for you. You’ll notice your terminal window or theme might change to something cooler (based on what you've setup in your config).

The Key Tmux Command (Prefix)

The main thing to remember is that CTRL + B is the base or prefix for all Tmux commands.

For example, if you want to split a window vertically, you would press:

CTRL + B + %

If you want to split it horizontally, press:

CTRL + B + "

As you can see, you always start with CTRL + B before any action.

Basic Tmux Tips and Tricks

  • Detach from Tmux: Press CTRL + B + D. This will kick you out of the tmux session but keep the session running in the background.
  • Detach from tmux session means closing tmux and going back to normal mode (normal terminal session no tmux) means going back to the bad side :) 
  • List all active sessions: Run `$ tmux ls` to see your active Tmux sessions.
  • Reattach to a session: Run `$ tmux att` to jump back into the last active session.
  • In tmux session run the following command only to test that tmux won't kill the server(sessions) once you detach, so for that run :
`$ ping google.com`

  • Detach from the session (CTRL + B + D) and then reattach using 

`$ tmux attach`

You’ll see that the session is still running and the ping is still active. You can even close the terminal, open a new one, and reattach it to the same session, and everything will remain the same.

Moving Around Like a Pro

Now let’s talk about moving between panes.

You can split your screen vertically or horizontally (as shown above). But to move between panes, you don’t need to use your mouse (no way!). Instead, you can use Vim-like navigation.

Press CTRL + B, then use h, j, k, or l to move between panes:

  • h: Move left
  • j: Move down
  • k: Move up
  • l: Move right

Once you are used to it you will be a super-duper hacker trust me :)

These keys are based on Vim’s navigation. If you don’t know Vim basics, you should learn it, but if you do, this will feel supernatural.

More Tmux Magic

  • Open a new window: Press CTRL + B + C.
  • Close a window: Type $ exit in the pane, and it’ll close.

Tmux is also awesome for SSH connections. Let’s say you’re SSH’ing into a server, running long processes like enumeration or other scripts. You can open Tmux, run your commands, and detach from the session. Even if you disconnect from SSH, your commands will keep running. Just reattach when you log back in!

Organizing with Sessions

What I usually do is create a Tmux session for each project or target I’m working on. For example, let’s say I’m working on a target like hackerone.com. I’d run:

$ tmux new-sess -s hackerone

This opens a new session named hackerone. Now, everything in that session is just for hackerone.

I can detach from it, and create another session for a different target (like nasa.com), and switch between them without losing anything. You can switch between sessions easily by pressing 

`CTRL + B + S` -> which lets you select the session you want to jump to.

Moving between windows

keep in mind :

- Sessions could have multiple windows 

- Windows could have multiple panes

If we have multiple windows and we want to move around between them, we could press

`CTRL + B + ANY_NUMBER`

like if we have 3 opened windows, and I wanted to move to the 2nd window:

`CTRL + B + 2`

as simple as that

and as you know we can have multiple panes in each windows, run your commands, and move around between your windwos or your panes.

for example, I used to create multiple windows one for subdomain discovery running all my tools (each tool in a specific pane)

another window could be for port scanning, or exploiting based on your preferences you could have as many as you can.

or you could live with only one window which will has multiple panes so you can run commands or tools.

Notes
*  btw you can edit your tmux config to fit your needs 
*  for example if you would change the prefix (Ctrl+B) to something else feel free to change it.
*  all the settings (configs) are default and it's fine to map em to fit your needs.

Final Words
There’s a lot more you can do with Vim and Tmux, but this should give you a solid start. Play around with it, get comfortable with the commands, and you’ll feel like a terminal wizard in no time.

Thanks for reading this far! If you did, drop a random comment or share a quote you like in the comments below.

happy hacking y'all!

#vim #hacking #terminal #tmux

Comments

Popular posts from this blog

Secure your Discord account with 2FA

How to get the [ IP, location ...etc ] of anyone visit your site in React/JavaScript