Even with bash completion, endlessly typing and tabbing through the directory tree to make a simple change to a config file quickly becomes tedious, so I concocted this script to make it somewhat more straightforward.
1 2 3 4 5 6 7 8 9 10 11
A relatively simple script, with a nice feature or two, it does a couple of things. First, it tests that the directory actually exists:
and then loops through all of the files in the directory using a glob and checks for a pattern match.
In order for the case statement to work, however, the directory path has to be stripped from the file name.
which turns, for example, $XDG_CONGIG_HOME/newsbeuter/conf into a
simple conf. This can then be evaluated for a match with the file names
case statement and passed to the
If no match is found, nothing (
:) is done.
Now, it is simply a matter of entering
xdg vimprobable and
$XDG_CONFIG_HOME/vimprobable/vimprobablerc is opened in Vim.
After using this script for a while it became clear to me that it has a significant drawback: too many applications place their config files in directories other than $XDG_CONFIG_HOME. So, with some help, I updated the script. It now covers all of the directories where you are likely to find dotfiles.
1 2 3 4 5 6 7 8 9 10 11 12
If you would prefer a more portable version—which still relies on GNU find—then you could simplify it like so:
1 2 3 4 5 6 7 8 9 10