aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2017-10-04qcd: Update comment about slash escapingHEADmasterTeddy Wing
I had forgotten to update the comment when I wrote 357eb2484bf58ed202b072b94fff54d81fe0fb49.
2017-10-04Homebrew/qcd.rb: Update to v0.2.1Teddy Wing
2017-10-04CHANGELOG: Describe changes for v0.2.1v0.2.1Teddy Wing
2017-10-04Merge branch 'allow-database-file-to-be-symlinked'Teddy Wing
2017-10-04qcd: Allow database file to be symlinkedTeddy Wing
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.
2017-10-04Merge branch 'fix-change-command-sed-substitution-escaping-for-bash-4'Teddy Wing
2017-10-04qcd: Update slash-escapes in change command for Bash 4Teddy Wing
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.
2016-12-03Homebrew/qcd.rb: Update to v0.2.0Teddy Wing
2016-12-03CHANGELOG: Describe changes for v0.2.0v0.2.0Teddy Wing
2016-12-03qcd: Add option to list shortcutsTeddy Wing
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.
2016-07-24Homebrew/qcd.rb: Update to v0.1.1Teddy Wing
2016-07-24Add CHANGELOGv0.1.1Teddy Wing
Include notes for the previous two releases and the current release in progress.
2016-07-24qcd: Prefix helper functions with `__qcd_`Teddy Wing
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.
2016-07-23Add Homebrew formulaTeddy Wing
* Enable installation via Homebrew on OS X. * Update the README to describe how to use Homebrew to install.
2016-07-22Remove 'new interface.txt'v0.1.0Teddy Wing
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.
2016-07-22Add README.mdTeddy Wing
Include a short description, example usage information, installation instructions, and license information.
2016-07-22Add license information (GPLv3)Teddy Wing
* COPYING file * Copyright headers on source files
2016-07-22qcd.bash-completion: Remove path variablesTeddy Wing
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.
2016-07-22Update Bash completion file to work with database-enabled versionTeddy Wing
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.
2016-07-22qcd: Run initial setupTeddy Wing
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`.
2016-07-21qcd: Add descriptive comment to `change_shortcut`Teddy Wing
Add a comment describing what those seemingly random slashes are for.
2016-07-21qcd: Enable `cd` into paths with spacesTeddy Wing
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
2016-07-21qcd: Quote the `$path` variableTeddy Wing
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
2016-07-21qcd: Only run `cd` if the given shortcut existsTeddy Wing
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.
2016-07-21qcd: When a shortcut is passed, `cd` into the corresponding directoryTeddy Wing
Look up the given shortcut in the database and change to the directory it points to.
2016-07-21qcd: Fix `absolute_path` functionTeddy Wing
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`)
2016-07-21qcd: Add "remove" commandTeddy Wing
Remove a given shortcut from the database.
2016-07-21qcd: Move "add" and "change" commands to their own functionsTeddy Wing
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.
2016-07-21qcd: Add "change" commandTeddy Wing
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.
2016-07-21qcd: Rename `find_shortcut` function to `shortcut_exists`Teddy Wing
This name makes more sense since it's meant for a test and doesn't return any information about the shortcut.
2016-07-21qcd: Only add shortcut to database if it's newTeddy Wing
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.
2016-07-21qcd: Add `setup` functionTeddy Wing
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.
2016-07-21qcd: Initial "add" command implementationTeddy Wing
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
2016-07-21qcd: Remove `return` from help branchTeddy Wing
Don't think it's necessary. Seems like after this branch executes, the later branches are ignored, which is what we want.
2016-07-21qcd: Option parsing skeletonTeddy Wing
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.
2016-07-21qcd: Update usage outputTeddy Wing
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.
2016-07-21qcd: Set config path locationsTeddy Wing
Use `XDG_CONFIG_HOME` (~/.config) to store our application support files. Put our database file in our directory there.
2016-07-21Add some ideas for what we want the new version to look likeTeddy Wing
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.
2016-07-21qcd: Add modeline to set Vim filetype for syntax highlightingTeddy Wing
2016-07-21Initial commit. First working version of qcd.v0.0.1Teddy Wing
The initial working `qcd` function and bash completion function copied from my dotfiles. Shortcuts and directory paths are specified manually in both scripts.