diff options
| author | Teddy Wing | 2016-07-21 23:20:37 -0400 |
|---|---|---|
| committer | Teddy Wing | 2016-07-21 23:20:37 -0400 |
| commit | 30fcb9ed86d95be7c33f527f04e167682728627a (patch) | |
| tree | 4627a2acc8eced19ca86775962e9dbebbf12fc15 | |
| parent | f0189d6dc374b4238892e3309e116317a6d8c48c (diff) | |
| download | qcd-30fcb9ed86d95be7c33f527f04e167682728627a.tar.bz2 | |
qcd: Enable `cd` into paths with spaces
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
| -rwxr-xr-x | qcd | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -68,10 +68,12 @@ function change_directory () { local shortcut=$1 if shortcut_exists $shortcut; then - cd $(awk -v shortcut="$shortcut" '{ + local directory=$(awk -v shortcut="$shortcut" '{ if ($1 == shortcut) - { print $2 } + { sub(/[[:space:]]*([^[:space:]]+[[:space:]]+)/,""); print } }' $QCD_DATABASE_FILE) + + cd "$directory" fi } |
