Skip to content

Instantly share code, notes, and snippets.

@pauloborges
Last active December 16, 2015 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pauloborges/5356257 to your computer and use it in GitHub Desktop.
Save pauloborges/5356257 to your computer and use it in GitHub Desktop.
Specification of a proposed alias system to goto utility. Download it at pauloborges/goto.

#Summary

The alias system allows the user to set shortcurs to goto commands. An intentionally side effect is to group all functionality inside goto command (and remove label command).

The user can add an alias:

$ goto alias add label "goto label"
label alias executes "goto label"

$ goto alias add g goto
g alias executes "goto"

Remove an alias:

$ goto alias rm label
label alias was removed.

Update an alias by add it using -u | --update.

##Persistence

With this system, we need to modify our persistence. Now, .goto is a folder:

.goto/
├─ labels
└─ aliases/
   ├─ g
   ├─ l
   └─ ...

Where labels is the former .goto file renamed, and aliases is a folder where all aliases will be stored.

Each alias is a executable text file with a single line: the command added by the user when registered the alias.

There is some pre-installed aliases:

  • g executes goto
  • l executes goto label
  • label executes goto label

If the user doesn't wants these default aliases, he can removes them by execute:

$ goto alias --remove-defaults

And if he wants to adds it back:

$ goto alias --add-defaults

##goto.sh

We need to prepend ~/.goto/aliases/ to the $PATH variable inside goto.sh (if the folder exists).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment