mirror of
https://github.com/cheat/cheat.git
synced 2025-09-01 01:28:30 +02:00
Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
09f821835c | |||
7e5e4315e5 | |||
869e7095f3 | |||
6dd8faf26a | |||
c0585ee55c | |||
c0d755e102 | |||
49e1fc46f4 | |||
3d90b26b04 | |||
3b73b9b06b | |||
74d1bc1ec7 | |||
78c76dc75a | |||
f204ed66e1 | |||
29c53b754d | |||
5a7fdfcca7 | |||
c3f082eccf | |||
808a2585ef | |||
c0aad062ec | |||
8ffeaa4211 | |||
c1d4c768de |
@ -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
110
README.md
@ -1,3 +1,6 @@
|
||||
[](https://pypi.python.org/pypi/cheat/)
|
||||
[](https://pypi.python.org/pypi/cheat/)
|
||||
|
||||
cheat
|
||||
=====
|
||||
`cheat` allows you to create and view interactive cheatsheets on the
|
||||
@ -7,66 +10,51 @@ remember.
|
||||
|
||||

|
||||
|
||||
`cheat` depends only on `python` and `pip`.
|
||||
|
||||
PyPI status:
|
||||
|
||||
[](https://pypi.python.org/pypi/cheat/)
|
||||
[](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
|
||||
----------
|
||||
|
||||
### Using pip ###
|
||||
It is recommended to install `cheat` with `pip`:
|
||||
|
||||
sudo pip install cheat
|
||||
```sh
|
||||
[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
|
||||
|
@ -38,7 +38,7 @@ 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.23')
|
||||
|
||||
# list directories
|
||||
if options['--directories']:
|
||||
|
@ -17,4 +17,3 @@ dd if=/dev/zero of=/dev/null bs=128M status=progress
|
||||
|
||||
# DD with "graphical" return
|
||||
dcfldd if=/dev/zero of=/dev/null bs=500K
|
||||
|
||||
|
@ -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 {} \;
|
||||
|
@ -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
|
||||
|
40
cheat/cheatsheets/nmcli
Normal file
40
cheat/cheatsheets/nmcli
Normal 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>
|
@ -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
|
||||
|
@ -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
11
cheat/cheatsheets/tree
Normal 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
|
@ -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
|
||||
|
38
cheat/cheatsheets/virtualenv
Normal file
38
cheat/cheatsheets/virtualenv
Normal 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
11
cheat/cheatsheets/xrandr
Normal 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
|
Reference in New Issue
Block a user