| Age | Commit message (Collapse) | Author |
|
I had forgotten to update the comment when I wrote
357eb2484bf58ed202b072b94fff54d81fe0fb49.
|
|
|
|
|
|
|
|
The `sed -i` calls in the "change" and "remove" commands will overwrite
a symlinked database file with a real file, destroying the symlink.
To prevent this and allow the database file to be symlinked (to, say,
allow it to be tracked in a dotfiles repo), use a redirection technique
as described here:
https://www.cyberciti.biz/faq/howto-prevent-sed-i-from-destroying-symlinks-on-linux-unix/
Using this alternate method, we preserve symlinks, and even create a
backup file as before.
|
|
|
|
I was getting this error when running `qcd`'s change command on a
machine using Bash 4.4.12:
$ sed -E "s/^shortcut .+$/shortcut ${p//\//\/}/" .config/qcd/database
sed: 1: "s/^shortcut .+$/shortcut ...": bad flag in substitute command: 'U'
The solution, as described here:
https://stackoverflow.com/questions/27787536/how-to-pass-a-variable-containing-slashes-to-sed/27788661#27788661
is to add an extra backslash to the parameter expansion. This appears to
work on both Bash 3 and 4 in my local manual tests.
|
|
|
|
|
|
Sometimes it's helpful to list the shortcuts you've added to help you
remember what they were. I had been doing `cat ~/.config/qcd/database`
for this, but it's nice to have it as part of the `qcd` command and also
to not have to type all that.
|
|
|
|
Include notes for the previous two releases and the current release in
progress.
|
|
Wasn't thinking about the fact that these helper functions get exposed
to the global namespace, which is _such_ a bad idea.
Rename these functions to something specific to the program to make them
harder to randomly come across and to have a better chance of not
overriding something that already exists.
|
|
* Enable installation via Homebrew on OS X.
* Update the README to describe how to use Homebrew to install.
|
|
This was our ideas file when implementing the new database supported
version of `qcd`. Now that it's working the way we wanted it to, this
ideas file can be removed.
|
|
Include a short description, example usage information, installation
instructions, and license information.
|
|
* COPYING file
* Copyright headers on source files
|
|
Assume we'll get these from the main `qcd` script as currently they're
sourced to the global environment. This way at least we're not repeating
those lines in two places.
|
|
Bash completion now works for the new database-backed `qcd`.
Arguments 1 and 2 are completed by searching the `qcd` database.
Argument 3 is completed using default Bash completion by setting
`COMPREPLY` to `()` and adding `-o default` to the `complete` call as
recommended here:
http://stackoverflow.com/questions/12933362/getting-compgen-to-include-slashes-on-directories-when-looking-for-files/19062943#19062943
Copied over the directory variables from the `qcd` script. Not sure if I
should be putting them somewhere else so they're not in two different
places. I probably should. I was also concerned that once the scripts
are sourced, these variables will be in a user's shell environment. That
doesn't feel right, but I'm going to ignore it for now.
|
|
In addition to creating the config directory, also touch the database
file to ensure it exists before we query it with `awk` in
`shortcut_exists`.
|
|
Add a comment describing what those seemingly random slashes are for.
|
|
Previously, the `awk` command would only print out the second column,
meaning that if we had a database entry like:
qproj /Users/user/code/Q Proj
`awk` would give us:
/Users/user/code/Q
(missing the " Proj" part).
Output all columns except the first using this `awk` substitution by Ed
Morton on Stack Overflow:
http://stackoverflow.com/questions/2626274/print-all-but-the-first-three-columns/18819899#18819899
|
|
If the path contains spaces, the path following the space will be lost
unless we quote the variable.
TODO: Get the `cd` command working with spaces
|
|
If we don't check that the shortcut exists before trying to `cd`, we end
up in the HOME directory, which is not what we want. We just want the
`qcd` command to fail silently.
|
|
Look up the given shortcut in the database and change to the directory
it points to.
|
|
This function wasn't correctly transforming paths into absolute paths.
Replace this with a different Stack Overflow solution, this time from
Ernest A:
http://stackoverflow.com/questions/4175264/retrieve-absolute-path-given-relative-linux-shell/20500246#20500246
(Modified to run in a subshell so we don't actually `cd`)
|
|
Remove a given shortcut from the database.
|
|
To make things cleaner, don't put the body of these commands directly in
the main `case` statement. Instead, put them in their own named
functions.
|
|
Option to change the path referenced by a given shortcut. Uses `sed` to
make the replacement and write out the updated database file. Using the
`-E` flag on `sed` so that the `+` regex operator works. The `-E` flag
works on OS X, but on Linux with GNU sed, it would be the `-r` flag
instead.
|
|
This name makes more sense since it's meant for a test and doesn't
return any information about the shortcut.
|
|
If an existing shortcut in the database matches the one you're trying to
add, it doesn't get added.
In the future we might want to output an error message to let users
know that there was a problem.
|
|
Should be run before accessing the database to set up configuration
directories necessary for the command to work.
Right now I'm not using the default directories, instead overriding the
`QCD_DATABASE_FILE` variable on the shell for a custom database
location. Haven't tested this yet, but figured I'd commit it and get
back to it later.
|
|
Add the specified shortcut and path to the database file. Expand the
given path to an absolute path so that it can be used from any working
directory.
Used "andsens"' answer on Stack Overflow for getting the absolute path:
http://stackoverflow.com/questions/7126580/expand-a-possible-relative-path-in-bash/17076258#17076258
|
|
Don't think it's necessary. Seems like after this branch executes, the
later branches are ignored, which is what we want.
|
|
We only need to support a single flag at a time. Everything else can be
regarded as a directory shortcut.
Allow both `-h` and `--help` to print usage information.
|
|
Going for documentation-driven programming. The new usage draft shows
how the new version of the command should be called, what options it
takes, and in essence what it should be able to do.
|
|
Use `XDG_CONFIG_HOME` (~/.config) to store our application support
files. Put our database file in our directory there.
|
|
Instead of shortcuts being specified manually in the scripts, they
should dynamically support on the fly adding, removing, and changing of
shortcuts.
This would allow for a lot more flexibility in the command's use, giving
us the ability to create a temporary shortcut to a directory that we may
only need for a few minutes or hours, at which point it can be deleted.
|
|
|
|
The initial working `qcd` function and bash completion function copied
from my dotfiles. Shortcuts and directory paths are specified manually
in both scripts.
|