aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
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.