Compare commits

...

47 Commits

Author SHA1 Message Date
Chris Lane
eff042d50b patch version bump 2016-08-05 15:18:52 -04:00
Chris Lane
f000756f2c Resolved merge-conflict. 2016-08-05 15:15:22 -04:00
Chris Lane
ef1dfb2168 Merge pull request #286 from poohzrn/master
Fix #281: Consistent description styles
2016-08-05 15:03:49 -04:00
Chris Lane
3c1b5c5860 Merge pull request #274 from ImmortalPC/master
[CHANGE] Add cheats for DD and SSH
2016-08-05 15:01:14 -04:00
Chris Lane
3494827403 Merge pull request #288 from rski/remove_prompt_function
Remove prompt_yes_or_no
2016-08-05 14:58:27 -04:00
Chris Lane
f0879831c5 Merge pull request #284 from dufferzafar/ansi
Add ANSI Color Chart
2016-08-05 14:57:18 -04:00
Chris Lane
8c056d09e9 Merge pull request #285 from dufferzafar/less
Update less cheatsheet
2016-08-05 14:56:14 -04:00
Chris Lane
dd8d0ae58b Merge pull request #282 from dufferzafar/master
Update git cheatsheet
2016-08-05 14:54:24 -04:00
Chris Lane
6cc99a2b6a Merge pull request #283 from dufferzafar/cpdf
Add cpdf cheatsheet
2016-08-05 14:52:47 -04:00
Shadab Zafar
70ad22c12e git: Undo parts of last commit
Added from: http://stackoverflow.com/a/4248269/2043048
2016-07-20 14:34:29 +05:30
Romanos Skiadas
b28e6a84ac Remove prompt_yes_or_no
This function is not used anywhere in the code.
2016-07-19 15:16:12 +03:00
Romanos Skiadas
bf4f1c80ca Style fixes
Don't use * imports, fix indentations, other small fixes
2016-07-19 14:50:51 +03:00
Lasse Nielsen
9cf1a5761d Fix #281: Consistent description styles 2016-07-18 17:25:06 +02:00
Shadab Zafar
13fdcec332 Add cheat on how to dump content of less to file 2016-07-16 18:47:19 +05:30
Shadab Zafar
b2feeab4e8 Add ANSI Color Chart 2016-07-16 18:41:17 +05:30
Shadab Zafar
c4b7fd507f Add cpdf cheatsheet
cpdf is a tool to slice and dice PDFs

I created this sheet on a boring day by copying text from
[here](http://www.coherentpdf.com/usage-examples.html) and then
cleaning things up a bit.
2016-07-16 18:37:12 +05:30
Shadab Zafar
b77aa0974b Update git cheatsheet 2016-07-16 18:21:07 +05:30
Chris Lane
3be95142ed v2.1.25 2016-05-29 21:47:22 -04:00
Chris Lane
bb324e94a4 Issue #278
Fixed a technical innacuracy in the `crontab` cheatsheet.
2016-05-29 21:03:58 -04:00
Chris Lane
7084ce2f45 Merge pull request #277 from caorong/master
origin Convert Unix timestamp to Date only works on Linux, add cheat which works on Mac
2016-05-29 21:00:57 -04:00
Chris Lane
905006f09c Merge pull request #280 from ybudimirov/ncdu
Ncdu cheatsheet
2016-05-29 20:59:16 -04:00
Chris Lane
06a368fb1f Merge pull request #276 from oliworx/patch-1
add cheatsheet for subversion (svn)
2016-05-29 20:58:16 -04:00
Yuriy Budimirov
6a9422502a Ncdu cheatsheet 2016-05-26 13:21:20 +03:00
caorong
41332f1d8a update timestamp convert cheat 2016-04-27 10:57:44 +08:00
ImmortalPC
b6d54b135c [CHANGE & ADD] Removing typo from SSH. Adding tip for emacs and ssh. Adding cheat for xxd 2016-04-19 13:45:47 +02:00
Oliver Kurmis
a3c682729e add cheatsheet for subversion (svn) 2016-04-13 17:27:37 +02:00
ImmortalPC
f38da23741 [CHANGE] Add cheats for DD and SSH 2016-04-05 17:09:49 +02:00
Chris Lane
20d985d993 Working around failed upload
pypi responded with an HTTP 500 when uploading the last version of
`cheat`, and this seems to have caused some problems. No changes were
made in this commit other than incrementing the version number in an
attempt to resolve this.
2016-03-24 12:41:40 -04:00
Chris Lane
09f821835c v2.1.23 2016-03-24 12:39:20 -04:00
Chris Lane
7e5e4315e5 Merge pull request #268 from pierrepo/master
Add options for pip and a new cheatsheet for virtualenv
2016-03-24 12:37:17 -04:00
Chris Lane
869e7095f3 Merge pull request #269 from VirenMohindra/update-readme
trivial readme.md correction
2016-03-24 12:34:51 -04:00
Viren Mohindra
6dd8faf26a trivial readme.md correction
availble -> available
2016-03-18 03:23:30 -05:00
Pierre Poulain
c0585ee55c Append virtualenvwrapper commands 2016-03-15 17:34:28 +01:00
Pierre Poulain
c0d755e102 Add virtualenv 2016-03-15 17:28:07 +01:00
Pierre Poulain
49e1fc46f4 Add --user and --upgrade options 2016-03-15 17:15:06 +01:00
Chris Lane
3d90b26b04 Merge pull request #266 from MinimaxHeadroom/add-tree-mod-dd-vim-find
Add cheatsheet for command `tree`. Edits or command additions to existing cheatsheets `dd`, `find`, `vim`.
2016-03-14 14:21:55 -04:00
Chris Lane
3b73b9b06b Merge pull request #264 from JindrichPilar/master
Added xrandr cheat
2016-03-14 14:17:14 -04:00
Chris Lane
74d1bc1ec7 Merge pull request #263 from omsobliga/master
Add examples for tmux
2016-03-14 14:14:55 -04:00
Chris Lane
78c76dc75a Merge pull request #267 from VHarisop/nmcli
Added nmcli cheatsheet
2016-03-14 14:14:21 -04:00
VHarisop
f204ed66e1 Added WiFi-specific commands 2016-03-11 03:41:26 +02:00
VHarisop
29c53b754d Added nmcli cheatsheet 2016-03-08 04:06:44 +02:00
mheadroom
5a7fdfcca7 Add tree cheatsheet. Small edits to improve clarity of, plus addition of some new commands to, dd, find, vim. 2016-03-04 04:35:41 -05:00
Jindrich Pilar
c3f082eccf Added xrandr cheat 2016-02-22 20:59:05 +01:00
lih
808a2585ef Add example for tmux 2016-02-20 11:09:02 +08:00
Chris Lane
c0aad062ec Trivial README edit. 2016-02-18 15:40:18 -05:00
Chris Lane
8ffeaa4211 README edits
- Replaced the broken PyPi badges with new ones
- Moved some content out of the README and into new wiki pages
- Applied syntax highlighting to shell examples
- Trivial content edits
2016-02-18 15:35:17 -05:00
Chris Lane
c1d4c768de CONTRIBUTING.md
- Added a paragraph on licensing
- Trivial edits
2016-02-17 14:12:58 -05:00
27 changed files with 494 additions and 112 deletions

View File

@@ -1,9 +1,17 @@
Contributing
============
If you would like to contribute cheetsheets or program functionality, please
fork this repository, make your changes, and send me a pull request.
fork this repository, make your changes, and submit a pull request.
Python code show follow the standards laid out by [PEP 8][].
Python code should conform to [PEP 8][].
Licensing
---------
By contributing to the project, you agree to license your work under the same
licenses as `cheat` itself. `cheat` is currently dual-licensed under the GPL3
and MIT licenses, though that could change without notice in the future.
`cheat`, however, will always remain free software (as in both "free as in
freedom" and "free as in beer") and shall always be licensed accordingly.
[PEP 8]: http://legacy.python.org/dev/peps/pep-0008/

110
README.md
View File

@@ -1,3 +1,6 @@
[![PyPI](https://img.shields.io/pypi/v/cheat.svg)](https://pypi.python.org/pypi/cheat/)
[![PyPI](https://img.shields.io/pypi/dm/cheat.svg)](https://pypi.python.org/pypi/cheat/)
cheat
=====
`cheat` allows you to create and view interactive cheatsheets on the
@@ -7,66 +10,51 @@ remember.
![The obligatory xkcd](http://imgs.xkcd.com/comics/tar.png 'The obligatory xkcd')
`cheat` depends only on `python` and `pip`.
PyPI status:
[![Latest Version](https://pypip.in/version/cheat/badge.png)](https://pypi.python.org/pypi/cheat/)
[![Downloads](https://pypip.in/download/cheat/badge.png)](https://pypi.python.org/pypi/cheat/)
Example
-------
The next time you're forced to disarm a nuclear weapon without consulting
Google, you may run:
cheat tar
```sh
cheat tar
```
You will be presented with a cheatsheet resembling:
```
```sh
# To extract an uncompressed archive:
tar -xvf /path/to/foo.tar
tar -xvf '/path/to/foo.tar'
# To extract a .gz archive:
tar -xzvf /path/to/foo.tgz
tar -xzvf '/path/to/foo.tgz'
# To create a .gz archive:
tar -czvf /path/to/foo.tgz /path/to/foo/
tar -czvf '/path/to/foo.tgz' '/path/to/foo/'
# To extract a .bz2 archive:
tar -xjvf /path/to/foo.tgz
tar -xjvf '/path/to/foo.tgz'
# To create a .bz2 archive:
tar -cjvf /path/to/foo.tgz /path/to/foo/
tar -cjvf '/path/to/foo.tgz' '/path/to/foo/'
```
To see what cheatsheets are availble, run `cheat -l`.
To see what cheatsheets are available, run `cheat -l`.
Note that, while `cheat` was designed primarily for *nix system administrators,
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
----------
It is recommended to install `cheat` with `pip`:
### Using pip ###
```sh
[sudo] pip install cheat
```
sudo pip install cheat
### Using homebrew ###
brew install cheat
### Manually ###
First install the required python dependencies with:
sudo pip install docopt pygments
Then, clone this repository, `cd` into it, and run:
sudo python setup.py install
[Other installation methods are available][installing].
Modifying Cheatsheets
@@ -82,7 +70,9 @@ in the `~/.cheat/tar` file.
Provided that you have an `EDITOR` environment variable set, you may edit
cheatsheets with:
cheat -e foo
```sh
cheat -e foo
```
If the 'foo' cheatsheet already exists, it will be opened for editing.
Otherwise, it will be created automatically.
@@ -99,17 +89,23 @@ Personal cheatsheets are saved in the `~/.cheat` directory by default, but you
can specify a different default by exporting a `DEFAULT_CHEAT_DIR` environment
variable:
export DEFAULT_CHEAT_DIR=/path/to/my/cheats
```sh
export DEFAULT_CHEAT_DIR='/path/to/my/cheats'
```
### Setting a CHEATPATH ###
You can additionally instruct `cheat` to look for cheatsheets in other
directories by exporting a `CHEATPATH` environment variable:
export CHEATPATH=/path/to/my/cheats
```sh
export CHEATPATH='/path/to/my/cheats'
```
You may, of course, append multiple directories to your `CHEATPATH`:
export CHEATPATH=$CHEATPATH:/path/to/more/cheats
```sh
export CHEATPATH="$CHEATPATH:/path/to/more/cheats"
```
You may view which directories are on your `CHEATPATH` with `cheat -d`.
@@ -117,39 +113,17 @@ You may view which directories are on your `CHEATPATH` with `cheat -d`.
`cheat` can apply syntax highlighting to your cheatsheets if so desired. To
enable this feature, set a `CHEATCOLORS` environment variable:
export CHEATCOLORS=true
```sh
export CHEATCOLORS=true
```
### Enabling Command-line Autocompletion ###
The `cheat/autocompletion` directory contains scripts to enable command-line
autocompletion for various shells. To activate autocompletion, simply copy the
appropriate script to the appropriate path on your system. (The "appropriate
path" will vary on a per-platform basis, so this documentation shall not
speculate as to where that may be.)
See Also:
---------
- [Enabling Command-line Autocompletion][autocompletion]
- [Related Projects][related-projects]
Related Projects
----------------
- [lucaswerkmeister/cheats][1]: An implementation of this concept in pure bash
that also allows not only for numerical indexing of subcomands but also
supports running commands interactively.
- [jahendrie/cheat][2]: A bash-only implementation that additionally allows for
cheatsheets to be created and `grep` searched from the command-line.
([jahendrie][] contributed key ideas to this project as well.)
- [`cheat` RubyGem][3]: A clever gem from 2006 that clearly had similar
motivations. It is unclear whether or not it is currently maintained.
- [`tldr`][tldr]: "Simplified and community-driven man pages".
- [dufferzafar/cheat][5]: An implementation in golang that has syntax highlighting and allows to copy cheats directly to clipboard.
[dotfiles]: http://dotfiles.github.io/
[jahendrie]: https://github.com/jahendrie
[1]: https://github.com/lucaswerkmeister/cheats
[2]: https://github.com/jahendrie/cheat
[3]: http://errtheblog.com/posts/21-cheat
[4]: https://github.com/chrisallenlane/cheat/pull/77
[5]: https://github.com/dufferzafar/cheat
[tldr]: https://github.com/tldr-pages/tldr
[autocompletion]: https://github.com/chrisallenlane/cheat/wiki/Enabling-Command-line-Autocompletion
[dotfiles]: http://dotfiles.github.io/
[installing]: https://github.com/chrisallenlane/cheat/wiki/Installing
[related-projects]: https://github.com/chrisallenlane/cheat/wiki/Related-Projects

View File

@@ -31,14 +31,14 @@ Options:
"""
# require the dependencies
from cheat import *
from cheat.utils import *
from cheat import sheets, sheet
from cheat.utils import colorize
from docopt import docopt
if __name__ == '__main__':
# parse the command-line options
options = docopt(__doc__, version='cheat 2.1.22')
options = docopt(__doc__, version='cheat 2.1.26')
# list directories
if options['--directories']:

72
cheat/cheatsheets/ansi Normal file
View File

@@ -0,0 +1,72 @@
# Reset
Color_Off='\e[0m' # Text Reset
# Regular Colors
Black='\e[0;30m' # Black
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
Yellow='\e[0;33m' # Yellow
Blue='\e[0;34m' # Blue
Purple='\e[0;35m' # Purple
Cyan='\e[0;36m' # Cyan
White='\e[0;37m' # White
# Bold
BBlack='\e[1;30m' # Black
BRed='\e[1;31m' # Red
BGreen='\e[1;32m' # Green
BYellow='\e[1;33m' # Yellow
BBlue='\e[1;34m' # Blue
BPurple='\e[1;35m' # Purple
BCyan='\e[1;36m' # Cyan
BWhite='\e[1;37m' # White
# Underline
UBlack='\e[4;30m' # Black
URed='\e[4;31m' # Red
UGreen='\e[4;32m' # Green
UYellow='\e[4;33m' # Yellow
UBlue='\e[4;34m' # Blue
UPurple='\e[4;35m' # Purple
UCyan='\e[4;36m' # Cyan
UWhite='\e[4;37m' # White
# Background
On_Black='\e[40m' # Black
On_Red='\e[41m' # Red
On_Green='\e[42m' # Green
On_Yellow='\e[43m' # Yellow
On_Blue='\e[44m' # Blue
On_Purple='\e[45m' # Purple
On_Cyan='\e[46m' # Cyan
On_White='\e[47m' # White
# High Intensity
IBlack='\e[0;90m' # Black
IRed='\e[0;91m' # Red
IGreen='\e[0;92m' # Green
IYellow='\e[0;93m' # Yellow
IBlue='\e[0;94m' # Blue
IPurple='\e[0;95m' # Purple
ICyan='\e[0;96m' # Cyan
IWhite='\e[0;97m' # White
# Bold High Intensity
BIBlack='\e[1;90m' # Black
BIRed='\e[1;91m' # Red
BIGreen='\e[1;92m' # Green
BIYellow='\e[1;93m' # Yellow
BIBlue='\e[1;94m' # Blue
BIPurple='\e[1;95m' # Purple
BICyan='\e[1;96m' # Cyan
BIWhite='\e[1;97m' # White
# High Intensity backgrounds
On_IBlack='\e[0;100m' # Black
On_IRed='\e[0;101m' # Red
On_IGreen='\e[0;102m' # Green
On_IYellow='\e[0;103m' # Yellow
On_IBlue='\e[0;104m' # Blue
On_IPurple='\e[0;105m' # Purple
On_ICyan='\e[0;106m' # Cyan
On_IWhite='\e[0;107m' # White

132
cheat/cheatsheets/cpdf Normal file
View File

@@ -0,0 +1,132 @@
# Read in.pdf, select pages 1, 2, 3 and 6, and write those pages to
# out.pdf
cpdf in.pdf 1-3,6 -o out.pdf
# Select the even pages (2, 4, 6...) from in.pdf and write those pages
# to out.pdf
cpdf in.pdf even -o out.pdf
# Using AND to perform several operations in order, here merging two
# files together and adding a copyright stamp to every page.
cpdf -merge in.pdf in2.pdf AND -add-text "Copyright 2014" -o out.pdf
# Read control.txt and use its contents as the command line arguments
# for cpdf.
cpdf -control control.txt
# Merge in.pdf and in2.pdf into one document, writing to out.pdf.
cpdf -merge in.pdf in2.pdf -o out.pdf
# Split in.pdf into ten-page chunks, writing them to Chunk001.pdf,
# Chunk002.pdf etc
cpdf -split in.pdf -o Chunk%%%.pdf -chunk 10
# Split in.pdf on bookmark boundaries, writing each to a file whose
# name is the bookmark label
cpdf -split-bookmarks 0 in.pdf -o @N.pdf
# Scale both the dimensions and contents of in.pdf by a factor of two
# in x and y directions.
cpdf -scale-page "2 2" in.pdf -o out.pdf
# Scale the pages in in.pdf to fit the US Letter page size, writing to
# out.pdf
cpdf -scale-to-fit usletterportrait in.pdf -o out.pdf
# Shift the contents of the page by 26 pts in the x direction, and 18
# millimetres in the y direction, writing to out.pdf
cpdf -shift "26pt 18mm" in.pdf -o out.pdf
# Rotate the contents of the pages in in.pdf by ninety degrees and
# write to out.pdf.
cpdf -rotate-contents 90 in.pdf -o out.pdf
# Crop the pages in in.pdf to a 600 pts by 400 pts rectangle.
cpdf -crop "0 0 600pt 400pt" in.pdf -o out.pdf
# Encrypt using 128bit PDF encryption using the owner password 'fred'
# and the user password 'joe'
cpdf -encrypt 128bit fred joe in.pdf -o out.pdf
# Decrypt using the owner password, writing to out.pdf.
cpdf -decrypt in.pdf owner=fred -o out.pdf
# Compress the data streams in in.pdf, writing the result to out.pdf.
cpdf -compress in.pdf -o out.pdf
# Decompress the data streams in in.pdf, writing to out.pdf.
cpdf -decompress in.pdf -o out.pdf
# List the bookmarks in in.pdf. This would produce:
cpdf -list-bookmarks in.pdf
# Outputs:
# Add bookmarks in the same form from a prepared file bookmarks.txt to
# in.pdf, writing to out.pdf.
cpdf -add-bookmarks bookmarks.txt in.pdf -o out.pdf
# Use the Split style to build a presentation from the PDF in.pdf,
# each slide staying 10 seconds on screen unless manually advanced.
# The first page, being a title does not move on automatically, and
# has no transition effect.
cpdf -presentation in.pdf 2-end -trans Split -duration 10 -o out.pdf
# Stamp the file watermark.pdf on to each page of in.pdf, writing the
# result to out.pdf.
cpdf -stamp-on watermark.pdf in.pdf -o out.pdf
# Add a page number and date to all the pages in in.pdf using the
# Courier font, writing to out.pdf
cpdf -topleft 10 -font Courier -add-text "Page %Page\nDate %d-%m-%Y" in.pdf -o out.pdf
# Two up impose the file in.pdf, writing to out.pdf
cpdf -twoup-stack in.pdf -o out.pdf
# Add extra blank pages after pages one, three and four of a document.
cpdf -pad-after 1,3,4 in.pdf -o out.pdf
# List the annotations in a file in.pdf to standard output.
cpdf -list-annotations in.pdf
# Might Produce:
# -- # Annotation text content 1 # -- # -- # Annotation text content 2
# --
# Copy the annotations from from.pdf to in.pdf, writing to out.pdf.
cpdf -copy-annotations from.pdf in.pdf -o out.pdf
# Set the document title of in.pdf. writing to out.pdf.
cpdf -set-title "The New Title" in.pdf -o out.pdf
# Set the document in.pdf to open with the Acrobat Viewer's toolbar
# hidden, writing to out.pdf.
cpdf -hide-toolbar true in.pdf -o out.pdf
# Set the metadata in a PDF in.pdf to the contents of the file
# metadata.xml, and write the output to out.pdf.
cpdf -set-metadata metadata.xml in.pdf -o out.pdf
# Set the document in.pdf to open in Acrobat Viewer showing two
# columns of pages, starting on the right, putting the result in
# out.pdf.
cpdf -set-page-layout TwoColumnRight in.pdf -o out.pdf
# Set the document in.pdf to open in Acrobat Viewer in full screen
# mode, putting the result in out.pdf.
cpdf -set-page-mode FullScreen in.pdf -o out.pdf
# Attach the file sheet.xls to in.pdf, writing to out.pdf.
cpdf -attach-file sheet.xls in.pdf -o out.pdf
# Remove any attachments from in.pdf, writing to out.pdf.
cpdf -remove-files in.pdf -o out.pdf
# Blacken all the text in in.pdf, writing to out.pdf.
cpdf -blacktext in.pdf -o out.pdf
# Make sure all lines in in.pdf are at least 2 pts wide, writing to
# out.pdf.
cpdf -thinlines 2pt in.pdf -o out.pdf

View File

@@ -14,7 +14,9 @@ SHELL=/bin/bash
# example entries
# every 15 min
*/15 * * * * /home/user/command.sh
# every midnight
0 * * * * /home/user/command.sh
* 0 * * * /home/user/command.sh
# every Saturday at 8:05 AM
5 8 * * 6 /home/user/command.sh

View File

@@ -1,5 +1,8 @@
# Print date in format suitable for affixing to file names
date +"%Y%m%d_%H%M%S"
# Convert Unix timestamp to Date
# Convert Unix timestamp to Date(Linux)
date -d @1440359821
# Convert Unix timestamp to Date(Mac)
date -r 1440359821

View File

@@ -18,3 +18,5 @@ dd if=/dev/zero of=/dev/null bs=128M status=progress
# DD with "graphical" return
dcfldd if=/dev/zero of=/dev/null bs=500K
# This will output the sound from your microphone port to the ssh target computer's speaker port. The sound quality is very bad, so you will hear a lot of hissing.
dd if=/dev/dsp | ssh -c arcfour -C username@host dd of=/dev/dsp

View File

@@ -40,5 +40,8 @@ find . -maxdepth 2 -name build -type d
# To search all files who are not in .git directory
find . ! -iwholename '*.git*' -type f
# Find all files that have the same node (hard link) as MY_FILE_HERE
# To find all files that have the same node (hard link) as MY_FILE_HERE
find . -type f -samefile MY_FILE_HERE 2>/dev/null
# To find all files in the current directory and modify their permissions
find . -type f -exec chmod 644 {} \;

View File

@@ -104,3 +104,23 @@ git clone --depth 1 <remote-url>
# To unshallow a clone
git pull --unshallow
# Create a bare branch (one that has no commits on it)
git checkout --orphan branch_name
# Checkout a new branch from a different starting point
git checkout -b master upstream/master
# Remove all stale branches (ones that have been deleted on remote)
# So if you have a lot of useless branches, delete them on Github and then run this
git remote prune origin
# The following can be used to prune all remotes at once
git remote prune $(git remote | tr '\n' ' ')
# Revisions can also be identified with :/text
# So, this will show the first commit that has "cool" in their message body
git show :/cool
# Undo parts of last commit in a specific file
git checkout -p HEAD^ -- /path/to/file

View File

@@ -16,11 +16,18 @@
# To switch between channel windows
ALT+<number>, eg. ALT+1, ALT+2
# To list the nicknames within a channel
# To list the nicknames within the active channel
/names
# To change the topic
# To change the channel topic
/topic <description>
# To quit irssi
# To limit channel background noise (joins, parts, quits, etc.)
/ignore #foo,#bar JOINS PARTS QUITS NICKS # Quieten only channels `#foo`, `#bar`
/ignore * JOINS PARTS QUITS NICKS # Quieten all channels
# To save the current Irssi session config into the configuration file
/save
# To quit Irssi
/exit

View File

@@ -1,2 +1,9 @@
# To disable the terminal refresh when exiting
less -X
# To save the contents to a file
# Method 1 - Only works when the input is a pipe
s <filename>
# Method 2 - This should work whether input is a pipe or an ordinary file.
Type g or < (g or less-than) | $ (pipe then dollar) then cat > <filename> and Enter.

11
cheat/cheatsheets/ncdu Normal file
View File

@@ -0,0 +1,11 @@
# Save results to file
ncdu -o ncdu.file
# Read from file
ncdu -f ncdu.file
# Save results to compressed file
ncdu -o-| gzip > ncdu.file.gz
# Read from compressed file
zcat ncdu.file.gz | ncdu -f-

40
cheat/cheatsheets/nmcli Normal file
View File

@@ -0,0 +1,40 @@
# Desc: Command line interface to NetworkManager
# Connect to a wireless access point - Parameters:
# <wiface> -- the name of your wireless interface
# <ssid> -- the SSID of the access point
# <pass> -- the WiFi password
nmcli d wifi connect <ssid> password <pass> iface <wiface>
# Disconnect from WiFi - Parameters:
# <wiface> -- the name of your wireless interface
nmcli d wifi disconnect iface <wiface>
# Get WiFi status (enabled / disabled)
nmcli radio wifi
# Enable / Disable WiFi
nmcli radio wifi <on|off>
# Show all available WiFi access points
nmcli dev wifi list
# Refresh the available WiFi connection list
nmcli dev wifi rescan
# Show all available connections
nmcli con
# Show only active connections
nmcli con show --active
# Review the available devices
nmcli dev status
# Add a dynamic ethernet connection - parameters:
# <name> -- the name of the connection
# <iface_name> -- the name of the interface
ncmli con add type ethernet con-name <name> ifname <iface_name>
# Bring up the ethernet connection
nmcli con up <name>

View File

@@ -4,6 +4,12 @@ pip search SomePackage
# Install some packages
pip install SomePackage
# Install some package in user space
pip install --user SomePackage
# Upgrade some package
pip install --upgrade SomePackage
# Output and install packages in a requirement file
pip freeze > requirements.txt
pip install -r requirements.txt

View File

@@ -32,3 +32,12 @@ ssh user@example.com -C -c blowfish -X
# Copy files and folders through ssh from remote host to pwd with tar.gz compression
# when there is no rsync command available
ssh user@example.com "cd /var/www/Shared/; tar zcf - asset1 asset2" | tar zxf -
# Mount folder/filesystem through SSH
# Install SSHFS from https://github.com/libfuse/sshfs
# Will allow you to mount a folder securely over a network.
sshfs name@server:/path/to/folder /path/to/mount/point
# Emacs can read file through SSH
# Doc: http://www.gnu.org/software/emacs/manual/html_node/emacs/Remote-Files.html
emacs /ssh:name@server:/path/to/file

20
cheat/cheatsheets/svn Normal file
View File

@@ -0,0 +1,20 @@
# update working copy from repository
svn update "/path"
# show changed files in working copy
svn status
# show what changed in local file
svn diff "/path/filename"
# add files or folders
svn add "path/item"
# revert local uncommited changes
svn revert "/path/file"
# commit changes to repo
svn commit -m "message" "/path"
# show help for 'svn diff'
svn help diff

View File

@@ -13,6 +13,12 @@ tmux attach -d
# Display session:
tmux ls
# Rename session:
Ctrl-b $
# Switch session:
Ctrl-b s
# Start a shared session:
tmux -S /tmp/your_shared_session
chmod 777 /tmp/your_shared_session

11
cheat/cheatsheets/tree Normal file
View File

@@ -0,0 +1,11 @@
# To display a recursive directory tree
tree
# To make tree output contents from path `/foo/bar`
tree /foo/bar
# To make tree omit any empty directories from the output
tree --prune
# To list directories only (`-d`), and at a max depth of two levels (`-L`)
tree -d -L 2

View File

@@ -23,7 +23,8 @@ B previous start of whitespace-delimited word
$ end of line
gg go to first line in file
G go to end of file
gk move down one displayed line
gj move up one displayed line
# Insertion
# To exit from insert mode use Esc or Ctrl-C
@@ -49,8 +50,14 @@ P paste before cursor
dd delete a line
d{motion} delete text that {motion} moves over
# Search and replace with the `:substitute` (aka `:s`) command
# Preceding a motion or edition with a number repeats it n times
:s/foo/bar/ replace the first match of 'foo' with 'bar' on the current line only
:s/foo/bar/g replace all matches (`g` flag) of 'foo' with 'bar' on the current line only
:%s/foo/bar/g replace all matches of 'foo' with 'bar' in the entire file (`:%s`)
:%s/foo/bar/gc ask to manually confirm (`c` flag) each replacement
# Preceding a motion or edition with a number repeats it 'n' times
# Examples:
50k moves 50 lines up
2dw deletes 2 words

View File

@@ -0,0 +1,38 @@
# Create new environment
virtualenv /path/to/project/env_name
# Create new environment and inherit already installed Python libraries
virtualenv --system-site-package /path/to/project/env_name
# Create new environment with a given Python interpreter
virtualenv /path/to/project/env_name -p /usr/bin/python/3.4
# Activate environnment
source /path/to/project/env_name/bin/activate
# Quit environment
deactivate
# virtualenvwrapper (wrapper for virtualenv)
# installation
pip install --user virtualenvwrapper
# configuration
# add in ~/.bashrc or similar
export WORKON_HOME=~/.virtualenvs
mkdir -p $WORKON_HOME
source ~/.local/bin/virtualenvwrapper.sh
# Create new environmment (with virtualenvwrapper)
mkvirtualenv env_name
# new environmment is stored in ~/.virtualenvs
# Activate environmment (with virtualenvwrapper)
workon env_name
# Quit environmment (with virtualenvwrapper)
deactivate
# Delete environmment (with virtualenvwrapper)
rmvirtualenv env_name

11
cheat/cheatsheets/xrandr Normal file
View File

@@ -0,0 +1,11 @@
# To enable HDMI2 output with maximal resolution:
xrandr --output HDMI2 --auto
# To enable HDMI2 output with specific resolution:
xrandr --output HDMI2 --mode 1280x800
# To enable HDMI2 output next to HDMI1 output:
xrandr --output HDMI2 --auto --right-of HDMI1
# To disable HDMI2 output:
xrandr --output HDMI2 --off

8
cheat/cheatsheets/xxd Normal file
View File

@@ -0,0 +1,8 @@
# Convert bin/string to hex.
# Result: 34322069732074686520736f6c7574696f6e0a
echo '42 is the solution' | xxd -p
# Convert hex to bin/string.
# Result: 42 is the solution
echo '34322069732074686520736f6c7574696f6e0a' | xxd -r -p

View File

@@ -1,10 +1,9 @@
from cheat import sheets
from cheat import utils
from cheat.utils import *
import os
import shutil
import subprocess
from cheat import sheets
from cheat.utils import die, editor
def copy(current_sheet_path, new_sheet_path):
""" Copies a sheet to a new path """
@@ -16,7 +15,7 @@ def copy(current_sheet_path, new_sheet_path):
# fail gracefully if the cheatsheet cannot be copied. This can happen if
# DEFAULT_CHEAT_DIR does not exist
except IOError:
die ('Could not copy cheatsheet for editing.')
die('Could not copy cheatsheet for editing.')
def create_or_edit(sheet):
@@ -84,5 +83,5 @@ def read(sheet):
if not exists(sheet):
die('No cheatsheet found for ' + sheet)
with open (path(sheet)) as cheatfile:
return cheatfile.read()
with open(path(sheet)) as cheatfile:
return cheatfile.read()

View File

@@ -1,7 +1,8 @@
from cheat import cheatsheets
from cheat.utils import *
import os
from cheat import cheatsheets
from cheat.utils import die
def default_path():
""" Returns the default cheatsheet path """
@@ -22,7 +23,7 @@ def default_path():
if not os.access(default_sheets_dir, os.R_OK):
die('The DEFAULT_CHEAT_DIR (' + default_sheets_dir +') is not readable.')
if not os.access(default_sheets_dir, os.W_OK):
die('The DEFAULT_CHEAT_DIR (' + default_sheets_dir +') is not writeable.')
die('The DEFAULT_CHEAT_DIR (' + default_sheets_dir +') is not writable.')
# return the default dir
return default_sheets_dir
@@ -81,10 +82,10 @@ def search(term):
for cheatsheet in sorted(get().items()):
match = ''
for line in open(cheatsheet[1]):
if term in line:
match += ' ' + line
if term in line:
match += ' ' + line
if not match == '':
if match != '':
result += cheatsheet[0] + ":\n" + match + "\n"
return result

View File

@@ -38,28 +38,13 @@ def editor():
elif os.environ['EDITOR'] == "":
die(
'Your EDITOR environment variable is set to an empty string. It must '
'be set to your editor\'s path.'
'Your EDITOR environment variable is set to an empty string. It must '
'be set to your editor\'s path.'
)
else:
return os.environ['EDITOR']
def prompt_yes_or_no(question):
""" Prompts the user with a yes-or-no question """
# Support Python 2 and 3 input
# Default to Python 2's input()
get_input = raw_input
# If this is Python 3, use input()
if sys.version_info[:2] >= (3, 0):
get_input = input
print(question)
return get_input('[y/n] ') == 'y'
def warn(message):
""" Prints a message to stderr """
print((message), file=sys.stderr)

View File

@@ -3,7 +3,7 @@ import os
setup(
name = 'cheat',
version = '2.1.22',
version = '2.1.26',
author = 'Chris Lane',
author_email = 'chris@chris-allen-lane.com',
license = 'GPL3',