Skip to content

ramarthyasc/superflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🌊 Superflow

Effortless navigation to any file/directory from anywhere in an instant, and Tmuxify every directory you navigate to. ie; Make your dev workflow superfast..

(Preview videos in the midsection)

Why ?

Whenever I start my system, I want to open a tmux session for one of my frequently used project directories (usually 1–4 of them) with a single key press from the bash shell. And whenever I needed to jump to a random project directory, I wanted it to open in a tmux session as fast as possible. This was the main trigger.

Second, whenever I’m inside Neovim (in a project directory) within a tmux session and I need to jump to another project directory in a new tmux window, I currently have to create a new window and then cd into that directory.I wanted this too to happen with just a single key press from inside Neovim.

thus.. superflow :))

🤖 Technologies :

  • Bash
  • FZF (Fuzzy finder)
  • Tmux
  • Nvim

🔷 Process of development & learnings :

  • Connected Fzf, Tmux and Nvim using Bash scripts so that anyone can just copy-paste these scripts and implement 'superflow' workflow in their linux/wsl machine quickly.
  • Learnings :
    1. Bash scripting
    2. Creating a user friendly linux CLI tool
    3. Cross process communications
    4. Bash Child processes, Forking, Environment variables inheritance

What is Superflow ?

An fzf-shell-tmux-nvim integration for programmers who need 'superflow' (read: 'instant') navigations between directories & for tmuxifying every directory you navigate to.

Opinionated for one specific context: superflow doesn't allow you to jump to a tmuxified directory from an nvim editor if the nvim was not opened inside a tmux environment (ie; you can't jump by pressing 'C-f' if you're inside nvim but not in a tmux session). Because, you shouldn't open nvim outside a tmux environment.

2 reasons :

1. If it is allowed to jump to a tmux session from nvim (which is not opened in a tmux session) by pressing 'C-f', then the unsaved file edits (buffer) in nvim will not be transferred to tmux. Thus causing you to lose the edits you made.

2. This would deprive you of tmux advantages.

How does this 'flow' (Read: 'work')?

1. While either outside or inside tmux :

To goto high frequent project directories (Ranked according to priority):-

(Ctrl-Space = Prefix key for both Bash and Tmux)
    Ctrl-Space + h = Open high frequent (rank 1)  project directory in tmux session
    Ctrl-Space + j = Open high frequent (rank 2)  project directory in tmux session
    Ctrl-Space + k = Open high frequent (rank 3)  project directory in tmux session
    Ctrl-Space + l = Open high frequent (rank 4)  project directory in tmux session

Video Demo 1 (Audio On):

superflow.1.mp4

2. While outside tmux (ie; You have just started the system, and you are in a shell not spawned by tmux) :

To goto a random project directory :-

    Ctrl-f = Shows up fzf (fuzzy finder); search the project directory - opens the directory in a tmux session

Video Demo 2 (Audio On):

superflow.2.mp4

3. While inside nvim in tmux Or inside a tmux session/tmux environment (Well, you shouldn't open nvim outside a tmux environment if you are a developer (& you won't need to.. if you are using 'superflow':)) ) :

To goto a random project directory :-

    Ctrl-f + s = Shows up fzf (fuzzy finder); search the project directory - opens up the directory in a tmux session
    Ctrl-f + f = Shows up fzf (fuzzy finder); search the project directory - opens up the directory in a tmux window in the same session

⚙️ SETUP / INSTALLATION

TIP : If you are using Qwerty keyboard, remap CTRL functionality to 'CAPSLOCK' key for better hand comfort & speed. You don't need CAPSLOCK.. well... do you ?

0. Required dependencies

  • tmux (terminal multiplexer)
  • fzf (command line fuzzy finder)

1. Create ~/.scripts directory

2. Copy tmux-script.sh, fzf-script.sh to ~/.scripts directory

2.1 For Nvim users: Copy nvimfzf-script.sh also to ~/.scripts directory

3. Put the below instructions into ~/.config/nvim/after/plugin/keymaps.lua file (Create the directories & file if not already exists)

    if vim.env.TMUX ~= nil and vim.env.TMUX ~= "" then
        vim.keymap.set("n", "<C-f>f", "<cmd>silent !tmux neww ~/.scripts/nvimfzf-script.sh 'w'<CR>")
        vim.keymap.set("n", "<C-f>s", "<cmd>silent !tmux neww ~/.scripts/nvimfzf-script.sh 's'<CR>")
    end

4. Put these instructions in ~/.tmux.conf :

set-option -g prefix 'C-@'
bind-key h run-shell "bash ~/.scripts/tmux-script.sh 'h'"
bind-key j run-shell "bash ~/.scripts/tmux-script.sh 'j'"
bind-key k run-shell "bash ~/.scripts/tmux-script.sh 'k'"
bind-key l run-shell "bash ~/.scripts/tmux-script.sh 'l'"

5. Put these instructions in ~/.bashrc (for bash users)

# scripts
source ~/.scripts/tmux-script.sh
source ~/.scripts/fzf-script.sh

5. Specify the High frequency directories, & custom session names for each directory by following the instruction below

5.1 Open tmux-script.sh & specify your high frequency directory locations :
    #HIGH FREQUENCY DIRECTORIES : CHANGE THESE
    HIGH_FREQ_DIR0="$HOME/edit-path-to-high-freq-directory0"
    HIGH_FREQ_DIR1="$HOME/edit-path-to-high-freq-directory1"
    HIGH_FREQ_DIR2="$HOME/edit-path-to-high-freq-directory2"
    HIGH_FREQ_DIR3="$HOME/edit-path-to-high-freq-directory3"

    HIGH_FREQ_DIR0_NAME="edit_here"
    HIGH_FREQ_DIR1_NAME="edit_here"
    HIGH_FREQ_DIR2_NAME="edit_here"
    HIGH_FREQ_DIR3_NAME="edit_here"

Eg:
HIGH_FREQ_DIR0="$HOME/edit-path-to-high-freq-directory0"
is changed to
HIGH_FREQ_DIR0="$HOME/projects/draw-code"

That's it ! Enjoy Superflow!!

🔨 How can this be Improved ?

- Until now, i don't have any problems with it in my workflow. Tell me if there is any..

🤝 Contributing

All contributions are welcome! Just open a pull request.

About

Effortlessly flow through files/directories while developing in the terminal

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages