News for hackers. Stuff that matters.
Re:Cdpath: Easily Navigate Directories in the Terminal by samuell on Thursday December 07, 2023 @02:10AM (#38553706)
Same here. I use "c.<bookmark-name>" so that I can hit "c." and tab twice to see all my available bookmarks.

Then I created a little bash f function:

    bookmark <bookmark-name>
... that adds such an alias pointing to the current folder to my aliases file, and sources it.

The source, if anybody is interested:

  bookmark() {
   if [[ ! $1 ]]; then
    echo "Please provide a bookmark name (will be prepended with 'c.'):";
    read name;
   else
    name=$1;
   fi
   dir=$(pwd);
   echo "alias c.$name='c $dir'" >> ~/.bash_aliases_local
   source ~/.bash_aliases_local
  }
Very efficient!

The reason I use c. rather than cd. is partly because I use an alias "c" all the time instead of "cd", that does all of this:

- cd into the folder

- run ls -ltr to see my last modified files at the bottom near the prompt.

- create an empty like with echo

- run pwd to print out the current folder path.

This was after I ran statistics on my bash history file and realized I constantly running ls -ltr and sometimes pwd in new folders.

Re:Cdpath: Easily Navigate Directories in the Terminal by samuell on Thursday December 07, 2023 @04:46AM (#38554620)
The source for my "c" bash function as well:

  c() {
    cd "$1";
    ls -ltra --color=always | tail -n 25;
    echo;
    pwd;
  }
Re:Cdpath: Easily Navigate Directories in the Terminal by samuell on Thursday December 07, 2023 @04:50AM (#38554648)
What was my surprising finding in this, is that I don't need to think much about how I name the bookmarks either.

I can just throw in new short-hand bookmarks for whatever I'm working at the moment.

If I happen to override any previous aliases, that doesn't matter much if I already forgot about that one anyways.

Another cool thing: You can check the end of your ~/.bash_aliases_local file to find out what are your most recent bookmarks, and in other words, what are the relevant folders you are using a lot right now.

One can of course also clean up this list of bookmark-aliases from time to time, but I often don't even care about that.