Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bahamas10/bash-interactivity
Utilities to work with bash while interactive
https://github.com/bahamas10/bash-interactivity
Last synced: about 2 months ago
JSON representation
Utilities to work with bash while interactive
- Host: GitHub
- URL: https://github.com/bahamas10/bash-interactivity
- Owner: bahamas10
- Created: 2013-10-03T16:44:17.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-03-25T05:05:24.000Z (over 10 years ago)
- Last Synced: 2024-05-08T20:01:55.659Z (8 months ago)
- Language: Shell
- Size: 141 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
bash-interactivity
============Utilities to work with bash while interactive
Usage
-----### `args`
Print arguments as read from the command line after wordsplitting, taken from
http://mywiki.wooledge.org/Arguments$ args hello "how are" you
3 args:### `cdir`
`cd` into the dirname of the last argument, useful for if you've ever tried
cd'ing into a file instead of a directory~ $ cd dev/something/file.txt
-bash: cd: file.txt: No such file or directory
~ $ cdir
~/dev/something $### `limitcolumns`
Limit the number of columns printed to terminal size or 80 if size cannot be
determined$ cat file.txt
some really long line
some short line
$ cat file.txt | limitcolumns 20
some really long li>
some short line- `$1` - the number of columns to limit the output to, defaults to terminal
width, falling back on `80`### `parr`
Print a bash array by name
This uses `eval`, as that is the only way to reference an array
that has its name stored in a variable while retaining indices (for
associative and sparse arrays).
More info on why indirection won't work for this here
http://mywiki.wooledge.org/BashFAQ/006#Evaluating_indirect.2Freference_variablesNote: the output generated by this function is NOT safe to eval
by the shell, this is just meant to inspect the contents of array,
like `var_dump` in PHP, or `console.dir` in JavaScript$ a=([0]="hello" [1]="how are" [5]="you")
$ parr a
(
[0]=`hello`
[1]=`how are`
[5]=`you`
)This will also work for associative arrays in Bash >= 4
$ parr BASH_ALIASES
(
[urldecode]=`python -c 'import sys;import urllib as u;print u.unquote_plus(sys.stdin.read());'`
[basher]=`~/.basher/basher`
[joyentstillpaying]=`sdc-listmachines | json -a -c "state !== 'running'" name state`
[gerp]=`grep`
[lsdisks]=`kstat -lc disk :::class | field 3 :`
[ls]=`ls -p --color=auto`
[cdir]=`cd "${_%/*}"`
[urlencode]=`python -c 'import sys;import urllib as u;print u.quote_plus(sys.stdin.read());'`
[cpp2c]=`sed -e 's#//\(.*\)#/*\1 */#'`
[externalip]=`curl -s http://ifconfig.me/ip`
[l]=`ls -CF`
[lsnpm]=`npm ls -g --depth=0`
[chomd]=`chmod`
)Exports
-------### Aliases
- `cdir`
### Functions
- `args`
- `limitcolumns`
- `parr`### Bash Completion
Provided for...
- `parr`
Installation
------------### bics
Use [bics](https://github.com/bahamas10/bics) to manage this plugin
After installing `bics`, install this plugin by running
bics install git://github.com/bahamas10/bash-interactivity.git
### manually
git clone git://github.com/bahamas10/bash-interactivity.git
cd bash-interactivity
cat interactivity.bash >> ~/.bashrc
exec bashLicense
-------MIT