Took a first stab at the README.

This commit is contained in:
Chris Lane 2013-08-10 18:56:50 -04:00
parent 58c01320f8
commit fa0843c337
2 changed files with 114 additions and 17 deletions

44
.cheat
View file

@ -1,5 +1,7 @@
#!/usr/bin/env python
cheatsheets = {
# @todo:
# - adb
# - at
@ -9,18 +11,13 @@ cheatsheets = {
# - fdisk
# - fstab
# - mount
# - mysqldump
# - mysqlimport
# - mongodump
# - mongoimport
# - nc
# - rsync
# - shred
# - useradd / adduser
# - xargs
# @see: http://www.thegeekstuff.com/2010/11/50-linux-commands/
########## apt-cache ##########################################################
'apt-cache' : '''
To search for apt packages:
@ -111,6 +108,18 @@ To create a symlink:
ln -s path/to/the/target/directory name-of-symlink
''',
########## mysqldump #########################################################
'mysqldump' : '''
To dump a database to a file:
mysqldump -uusername -ppassword the-database > db.sql
To dump a database to a .tgz file:
mysqldump -uusername -ppassword the-database | gzip -9 > db.sql
To dump all databases to a file:
mysqldump -uusername -ppassword --all-databases > all-databases.sql
''',
########## netstat ###########################################################
'netstat' : '''
To view which users/processes are listening to which ports:
@ -137,6 +146,23 @@ To replace all occurrences of "day" with "night" on stdin:
echo 'It is daytime' | sed s/day/night/
''',
########## shred ##############################################################
'shred' : '''
To shred a file (5 passes) and verbose output:
shred -n 5 -v file.txt
To shred a file (5 passes) and a final overwrite of zeroes:
shred -n 5 -vz file.txt
To do the above, and then truncate and rm the file:
shred -n 5 -vzu file.txt
To shred a partition:
shred -n 5 -vz /dev/sda
Remember that shred may not behave as expected on journaled file systems if file data is being journaled.
''',
########## split #############################################################
'split' : '''
To split a large text file into smaller files of 1000 lines each:
@ -223,9 +249,7 @@ tar -cjvf /path/to/foo.tgz /path/to/foo/
}
# Cheatsheets can be aliased under a different keyphrase like this:
#cheatsheets['dbus'] = cheatsheets['notify-send']
#cheatsheets['imagick'] = cheatsheets['convert']
#cheatsheets['redirection'] = cheatsheets['stdout']
cheatsheets['dbus'] = cheatsheets['notify-send']
cheatsheets['imagick'] = cheatsheets['convert']
cheatsheets['redirection'] = cheatsheets['stdout']

View file

@ -1,9 +1,82 @@
Cheat
=====
- overview
- obligatory xkcd (http://xkcd.com/1168/)(Embed: http://imgs.xkcd.com/comics/tar.png)
- examples
- subcommands
- anything, really
- Installing (link to dotfiles.github.com)
- help
`cheat` allows you to create and view interactive cheatsheets on the
command-line. It was designed to help \*nix system administrators remember
options for commands that they use frequently, but not frequently enough to
remember.
![The obligatory xkcd](http://imgs.xkcd.com/comics/tar.png 'The obligatory xkcd')
`cheat` depends only on python.
Examples
--------
The next time you're forced to disarm a nuclear weapon without consulting
Google, you may run:
```sh
cheat tar
```
You will be presented with a cheatsheet resembling:
```text
To extract an uncompressed archive:
tar -xvf /path/to/foo.tar
To extract a .gz archive:
tar -xzvf /path/to/foo.tgz
To create a .gz archive:
tar -czvf /path/to/foo.tgz /path/to/foo/
To extract a .bz2 archive:
tar -xjvf /path/to/foo.tgz
To create a .bz2 archive:
tar -cjvf /path/to/foo.tgz /path/to/foo/
```
To see what cheatsheets are availble, run `cheat` with no arguments.
Note that, while `cheat` was designed primarily for *nix system administrators,
it is agnostic as to what content it stores. If you would like to use `cheat`
to store notes on your favorite cookie recipes, feel free.
Installing
----------
Do the following to install `cheat`:
1. Clone this repository and `cd` into it
2. Run `sudo ./install`
The `install` script will copy a python file into `/usr/local/bin/`, and will
also create a hidden file (containing the cheatsheet content) in your home
directory.
Modifying Cheatsheets
---------------------
The value of `cheat` is that it allows you to create your own cheatsheets - the
defaults are meant to serve only as a starting point, and can and should be
modified.
To modify your cheatsheets, edit the `~/.cheat` file, which simply contains a
python dictionary. To add new cheatsheets, you need only append new key/value
pairs to the dictionary.
Note that `cheat` supports subcommands, such that (for example) `git` and `git
commit` may each be assigned their own cheat sheets.
After you've customized your cheatsheets, I urge you to track `.cheat` along
with your [dotfiles][].
Contributing
------------
If you would like to contribute additional cheatsheets for basic \*nix
commands, please modify the `.cheat` file and send me a pull request.
[dotfiles]: http://dotfiles.github.io/