I found a short script to enable note-taking on onethingwell, which includes this:
function n { nano ~/n/$1.txt }
I'd like to extend it to do tab completion, so that if I want to edit the pre-existing note 'foobar' (~/n/foobar.txt) I can type foo[TAB]
and have it automatically complete to foobar
, rather than having to type in 'foobar' every time. The problem is that bash's built-in tab completion seems to be centered around the current directory, so if I'm in a folder that isn't ~/n, then my tab completion fails -- or, worse, completes to the wrong thing, since perhaps I have a file named 'footastic' in ~/snafu/ (meaning I type $ n foo[TAB]
, and instead of seeing $ n foobar
, I look at my input and see: $ n footastic
.
So, after all that preamble, here's the question: if it's possible, how can I tell bash that after I type 'n', for just this once I want it to assume that we're completing using the files in ~/n for completion, rather than using the files in the current directory?
If you understood all that e-mumbling, congratulations, and if you can answer that, thank you very much!