I have a Python script, called t.py and a bash alias "t" that calls it. I use it for quick navigation in the terminal instead of "cd" and "pushd/popd".
The basic format is: "t <shortcut" while just "t" prints out all the shortcuts and waits for user input.
So, "t 1" goes to parent directory, faster than "cd .."
Then, "t 4" goes to "cd ../../../.."
And of course "t" will print out all the options.
"t a" goes to my main development git worktree, while "t b" goes to place I build from.
But the real star is the history. I embedded "`save_t_history`" into my bash prompt. That's another scropt that saves the current directory to a history file, then removes duplicates so staying in the same directory doesn't accumulate. Typing "t h" shows the history back to about 25 unique directories. Typing "t h1" goes to the last directory you were in. "t h5" goes five ago. I be working in tmux in one pane, and then jump to another and type "t h0" to bring it to the same directory.
This is basically my bread and butter for getting around.
I would post the code, but a.) it's on a work computer so technically property of my company and b.) it's a mess so I'd recommend others just build their own version.
A hint to get started is that the "t" alias is an alias for "cd `python3 /opt/t.py`"
I also have 't' as a shortcut, but 't' creates a randomly named directory in /tmp and jumps into it. 't <name>' creates a directory ~/workspaces/<name>_<datetime> and jumps into it.
'tl' always cd's into the latest directory created using 't'. Really useful if you are messing around with code and serverside stuff.
The basic format is: "t <shortcut" while just "t" prints out all the shortcuts and waits for user input.
So, "t 1" goes to parent directory, faster than "cd .." Then, "t 4" goes to "cd ../../../.." And of course "t" will print out all the options.
"t a" goes to my main development git worktree, while "t b" goes to place I build from.
But the real star is the history. I embedded "`save_t_history`" into my bash prompt. That's another scropt that saves the current directory to a history file, then removes duplicates so staying in the same directory doesn't accumulate. Typing "t h" shows the history back to about 25 unique directories. Typing "t h1" goes to the last directory you were in. "t h5" goes five ago. I be working in tmux in one pane, and then jump to another and type "t h0" to bring it to the same directory.
This is basically my bread and butter for getting around.
I would post the code, but a.) it's on a work computer so technically property of my company and b.) it's a mess so I'd recommend others just build their own version.
A hint to get started is that the "t" alias is an alias for "cd `python3 /opt/t.py`"