Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dawsbot/pluc
:ok_hand: Instant terminal aliases
https://github.com/dawsbot/pluc
alias developer-tools shell terminal
Last synced: about 7 hours ago
JSON representation
:ok_hand: Instant terminal aliases
- Host: GitHub
- URL: https://github.com/dawsbot/pluc
- Owner: dawsbot
- License: mit
- Created: 2017-01-26T07:33:03.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-29T16:26:16.000Z (almost 6 years ago)
- Last Synced: 2024-10-28T14:59:27.048Z (22 days ago)
- Topics: alias, developer-tools, shell, terminal
- Language: JavaScript
- Homepage:
- Size: 71.3 KB
- Stars: 27
- Watchers: 4
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
> :ok_hand: Create permanent terminal aliases instantly
β οΈUnder construction, beware of breaking changes β οΈ
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url]
## Usage
Save a new alias forever
```sh
$ pluc
```Leave out "`command`" and pluc will use your last command from shell history.
```sh
$ pluc
```
Here's what this could look like:
```sh
$ pluc serve "python -m SimpleHTTPServer"π Aliased "serve" to "python -m SimpleHTTPServer" π
```or
```sh
$ pluc ya "yarn add"π Aliased "ya" to "yarn add" π
$ ya react #Your new alias is instantly usable
```
## Install
1. npm install
```sh
$ npm install --global pluc
```2. Source pluc in your shell
Now source the pluc output file in your shell. Paste this in your bash profile (~/.bashrc, ~/.zshrc, ~/.bash_profile, , or ~/.profile).
```sh
source "$(pluc-cli --destinationPath)" #source pluc aliases on shell startup
function pluc() { #call pluc-cli and source new alias immediatly
pluc-cli "$@"
source "$(pluc-cli --destinationPath)"
}
```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
```sh
$ 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.
## More Examples
Imagine you ssh to this machine often:
```sh
$ ssh [email protected]
# ssh: Successfully ssh'd to example.org!
```But truly, you do that most days. Why should you type it out?
```sh
$ pluc sshme
# π Aliased "sshme" to "ssh [email protected]" π$ 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:
```sh
$ 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:
```sh
$ 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
```sh
$ $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
```sh
$ $EDITOR $(pluc --destinationPath)
```:warning: Do not edit the output shell file, it gets deleted on re-render (often) :warning:
## 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:
```sh
$ 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
```sh
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.
```sh
$ 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?
```json
{
"gi": "git init",
"ga": "git add"
}
```* The history inferred by `pluc ` alone is not accurate.
* History is obtained with [@dawsbot/shell-history](https://github.com/dawsbot/shell-history). Please open an issue there.## 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`](https:///github.com/dawsbot/shell-history) package. PR's welcome.
## License
MIT Β© [Dawson Botsford](http://dawsonbotsford.com)
[npm-image]: https://badge.fury.io/js/pluc.svg
[npm-url]: https://npmjs.org/package/pluc
[travis-image]: https://travis-ci.org/dawsbot/pluc.svg?branch=master
[travis-url]: https://travis-ci.org/dawsbot/pluc
[xo-image]: https://img.shields.io/badge/code_style-XO-5ed9c7.svg
[xo-url]: https://github.com/sindresorhus/xo