terminal-shortcuts v1.1.0
terminal-shortcuts

Save time and keystrokes by defining shortcuts for often-visited paths when navigating folders in the terminal.
~ $ ts-add proj /Users/me/Documents/projects
~ $ ts proj
~/Documents/projects $Getting Started
The toolkit consists of three parts
- the
ts-lookuptool- given a shortcut, this tool returns a target path
- the
ts-addandts-rmtools- adds and removes shortcut to/from the shortcut file
- batch and shell scripts
ts- batch script, acts likecdand changes directory to whatever the given shortcut expands to (windows only)ts-cd/ts-pushd- shell script wrappers forcdandpushd, though these can't be run directly (read more below)
Install them all globally:
npm install terminal-shortcuts -gAdd some shortcuts:
$ ts-add docs /Users/user/Documents
$ ts-add proj /Users/user/Documents/projectsTest the setup in a terminal/console window: run ts-lookup <shortcut> and make sure it prints the corresponding target, e.g.:
$ ts-lookup docs
/Users/user/Documents
$ ts-lookup proj
/Users/user/Documents/projectsShell setup (Linux / OS X)
Because shell scripts run in a sub-shell when executed, they cannot change directory of the parent shell. To make the ts-cd and ts-pushd scripts work as intended, set up aliases that source the scripts:
# create aliases
$ alias ts="source ts-cd"
$ alias tsp="source ts-pushd"
# use alias to change directory using the ts-cd script:
$ ts proj
# make sure we end up in the expected directory:
/Users/user/Documents/project $If you use bash, add the aliases to ~/.bash_profile to make them available in all shells. Also, feel free to use whatever aliases you like - I prefer go rather than ts, but I guess it might clash if you're programming with go-lang.
Shortcut format
Define shortcuts in any of the following formats:
docs:/Users/user/Documents- maps a shortcut,docsto a path/Users/user/Documentsproj:<docs>/projects- maps a shortcut,projto a path/Users/user/Documents/projectsusing another shortcutdocsas basesrc:<proj>/*/src- maps a shortcutsrcto a path/Users/user/Documents/projects/x/srcusing the current working directory as a base, i.e: -/Users/user/Documents/projects/project-a/srcif thecwdis anywhere below/Users/user/Documents/projects/project-a-/Users/user/Documents/projects/project-b/srcif thecwdis anywhere below/Users/user/Documents/projects/project-b- very useful for projects that have a deep, but known, directory structure and you need to navigate wihtin it regardless of what project you're currently working in
Also:
- Any shortcut that is not found is treated as a literal folder name, so e.g.
ts-lookup boguswill returnbogus. - Arguments can be "chained" so that e.g.
ts-lookup proj a dist docswill return/Users/user/Documents/projects/a/dist/docs, assuming that path exists
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
Release History
1.1.0
* added command `ts-add` to add shortcuts from the command line
* added command `ts-rm` to remove shortcuts from the command line1.0.0
* Inital release