This is quick pair of functions inspired by the "Elderscrolls III: Morrowind" traveling spells.
Allow the user to mark and quickly return to an arbitrary location (i.e. file path) by typing a keyword.
- increased navigation speed to arbitrary locations.
- E.G. I have a kubernetes object example directory buried within a private repo. Rather than spamming 'tab' to avoid typing the path, I can simply type
markto save the location andrecallto return to it, regardless of the shell.
- E.G. I have a kubernetes object example directory buried within a private repo. Rather than spamming 'tab' to avoid typing the path, I can simply type
Here's a quick and dirty echo to add the functions to your .zshrc
echo "Adding mark and recall functions to $PWD/.zshrc"
echo "
# mark and recall functions for quick travel
function mark {
echo $PWD >> ~/.mark_history
echo $PWD
}
function recall {
cd $(tail -n 1 ~/.mark_history)
}" >> ~/.zshrc && \
source ~/.zshrc
Once the functions have been added to your .zshrc, simply type mark in your console and the function will do the following:
- the mark function writes the
$PWDto an arbitrary file named.markin your home directory- this allows the marked
$PWDto be accessed in any shell with the the mark & recall functions loaded via .zshrc - mark runs cat on the newly created file for reference & confirmation of functionality.
- this allows the marked
Type recall into the console and the function runs a simple cd using the path written in ~/.mark
- only one location can be used
This script is super duper simple so even if you run into problems, it should be easy to debug. It should work in bash but that hasn't been tested.