pluc

0.1.3 • Public • Published

pluc

NPM version Build Status XO code style

👌 Create permanent terminal aliases instantly

logo

Install

$ npm install --global pluc

Now source the pluc output file in your shell. Paste this in your bash profile (~/.bashrc, ~/.zshrc, ~/.bash_profile, , or ~/.profile).

source "$(pluc-cli --destinationPath)"
function pluc() {
  pluc-cli "$@"
  source "$(pluc-cli --destinationPath)"
}

That also sets up a function to immediately source new aliases. Should you ignore the above bash code, you'd need to manually resource the pluc shell file per session and after adding a new alias.


Verify Installation

$ pluc --sourcePath
# Should output a json filepath, not an error. 

Your bash aliases are generated from that JSON object. You don't need to pay attention to that in most cases. That's covered in depth in the "About" section below.


Usage

Save a new alias forever

$ pluc <alias> <command>

Leave out command and pluc will infer your last entered command

$ pluc <alias>

Examples

Imagine you ssh to this machine often:

$ ssh username@username.example.org
# ssh: Successfully ssh'd to example.org! 

But truly, you do that most days. Why should you type it out?

$ pluc sshme
# 👌 Aliased "sshme" to "ssh username@username.example.org" 👌 
 
$ sshme
# ssh: Successfully ssh'd to example.org! 

Not only is the alias sshme instantly available, it's forever available in any new sessions. The alternative is to save an alias in your bash profile. It's not only time consuming to open and edit, but you won't be able to use that alias until you source it.


Or let's say you do web development and need a web server often:

$ pluc serve "python -m SimpleHTTPServer"
# 👌 Aliased "serve" to "python -m SimpleHTTPServer" 👌 
 
$ serve
# Serving HTTP on 0.0.0.0 port 8000 ... 

Although it's always recommended that you quote the command for safety with bash argument splitting, your second argument can contain spaces! Parsing of this is done on your behalf by pluc. If your command contains flags though, you must quote it, which is why it's not a good habit.


If you want to see the full list of commands:

$ pluc --help

About

pluc uses a single JSON object to store aliases. Since JSON is already key-value based, it's a perfect data format. To manually edit the JSON source file (you absolutely will eventually) enter

$EDITOR $(pluc --sourcePath)

After any new alias is added to pluc, the render function is called which builds a shell file. The shell output is what you source'd at the very beginning. To see it right now, enter

$EDITOR $(pluc --destinationPath)

⚠️ Do not edit the output shell file, it gets deleted on re-render (often) ⚠️


Backup important aliases

Are you saving important aliases or a large amount of them? If so, back these up.

Backup to Dropbox

First find the path your config file is saved in:

$ pluc --sourcePath
# /Users/dawsonbotsford/Library/Preferences/pluc-nodejs/config.json 

This file needs to be moved into Dropbox and symlinked back to the original location

mv /Users/dawsonbotsford/Library/Preferences/pluc-nodejs/config.json ~/Dropbox/
ln -s ~/Dropbox/config.json /Users/dawsonbotsford/Library/Preferences/pluc-nodejs/config.json

Backup to git

Alternatively, use git to manually version control.

$ pluc --sourcePath
# /Users/dawsonbotsford/Library/Preferences/pluc-nodejs/config.json 
cd /Users/dawsonbotsford/Library/Preferences/pluc-nodejs
$ git init
# add remote, and push! 

FAQ

  • Why not use the source command in my terminal?

    • source is only available within your current shell. As soon as you start a new session, your alias is gone.
  • How can I edit my aliases?

    • $ $EDITOR $(pluc --sourcePath)
  • Why store the data as a JSON object?

    • If JSON objects are used as the source of truth, a variety of render methods can be used. This means that any output format (vimrc, sublime snippets, etc.) which is key-value based can be generated using pluc.
  • What's one of these "pluc JSON objects" actually look like?

{
  "gi": "git init",
  "ga": "git add"
}
  • The history inferred by pluc <alias> alone is not accurate.

Compatibility Issues

  • pluc will not create valid aliases on Windows. Windows does not save terminal history.

  • pluc will not work with fish shell. It likely will not work for shells beyond bash or zsh. This is because of the parse function in @dawsbot/shell-history package. PR's welcome.

License

MIT © Dawson Botsford

Readme

Keywords

Package Sidebar

Install

npm i pluc

Weekly Downloads

5

Version

0.1.3

License

MIT

Last publish

Collaborators

  • dawsonbotsford