Tools and things that make my life easier - y'all might like them too
supercd.sh
I use this tool as a replacement (or frontend) to cd
. It will seek my home directory for a single directory that matches the input regular expression and changes my current working directory to that directory.
Syntax: supercd.sh [--verbose] pattern
| Option | Description | Default |
|————————-|————————–|——————————————-|
| -v
| Enable verbose debugging | Debugging is not enabled |
$ # This demonstrates what happens if your don't source the tool
$ supercd.sh foobar
Note: /home/mrbruno/bin/supercd.sh is not sourced
$ # The target does not exist
$ supercd foobar
No matches for foobar
$ # Create the target
$ mkdir ~/foobar
$ # Identify original directory
$ pwd
/home/mrbruno/repos/toys/tmp/20220312091536736347380
$ # Change to destination
$ supercd foobar
/home/mrbruno/foobar
$ # Prove we have changed to the directory
$ pwd
/home/mrbruno/foobar
$
$ supercd.sh foobar
Note: /home/mrbruno/bin/supercd.sh is not sourced
$
$ supercd foobar
No matches for foobar
$
$ mkdir ~/foobar ~/foobar-foo
$ supercd foobar
Too many matches for foobar
/home/mrbruno/foobar-foo
/home/mrbruno/foobar
$ supercd foobar\$
/home/mrbruno/foobar
$
The tool makes use of a Python script to look at the user’s home directory and locate directories that match the pattern. The Python script will not show errors by default but they can be displayed by using the debugging option:
$ supercd -v foobar
2022-03-12 10:11:19,166 INFO /home/mrbruno/bin/supercd.py:22 listdir('/home/mrbruno/extra/lost+found') error: PermissionError(13, 'Permission denied')
Too many matches for -v foobar
/home/mrbruno/foobar-foo
/home/mrbruno/foobar
$
sueprcd.sh
so I could set up an alias to do the sourcing automatically so I don’t have to think about it:
alias supercd='. supercd.sh'
You might wish to add such an alias to your $HOME/.bashrc
.