Improving my dev workflow

·

2 min read

Little backstory:

I was using gnome-terminal ever since I completely moved to Linux, no dual boot just plain ol' Linux.

This was fine, but I noticed that it was kind of slow but usable. You could feel it load up. So after a few days of looking for an alternative, I landed on alacritty and yes it's built using Rust - the lord's language.

fast forward a week later:

After a few days of tinkering with it, and configuring it to meet my standards - they aren't that high, to be honest, I'm quite satisfied with the defaults. I got it working and completely replaced the gnome terminal. The only downside is that s alacritty doesn't support tabs, now this annoyed me so much, but I also liked using alacritty and I wasn't going to start searching for another alternative.

So I did what every other developer can. Wrote a simple script to allow me to create new Tmux sessions working just like tabs. I know, my genius sometimes scares me too. Having worked with Tmux for a while, it was fairly easy to script it out.

Some of the issues I was trying to fix were:

  • Since most of my projects live on the Desktop, I need to be able to cd to the Desktop, pick a folder/project, and create a new Tmux session attached to that folder. If I want to open a different folder, detach it from that session and create a new one ( where tabs would have come in handy).

  • When I'm done with the new session exit it, and search for existing Tmux sessions, (they match the folders/projects name) and attach to it.

It does rely heavily on fuzzy finder (fzf) so make sure it's installed.

I managed to come up with this

#!/usr/bin/env bash

ATTACH_OR_CLOSE=$1
BASE_PATH=~/Desktop/

if [ "$ATTACH_OR_CLOSE" == "dd" ]; then
    tmux detach-client
elif [ "$ATTACH_OR_CLOSE" == "attach" ]; then
    # list active sessions in bg; get value before the colon pipe to fzf
    SESSION=`tmux ls| cut -d':' -f1 | fzf`
    tmux attach-session -t $SESSION
else
    SESSION_NAME=`ls ~/Desktop/ | fzf`
    cd $BASE_PATH$SESSION_NAME
    #Launch tmux session
    tmux new-session -d -s "$SESSION_NAME"
    tmux attach-session -t "$SESSION_NAME"
fi

You can check out some of my config files on this repo