cheat-fork-echo/cheat

94 lines
2.0 KiB
Plaintext
Raw Normal View History

2013-07-31 04:48:07 +02:00
#!/usr/bin/env python
import sys
2013-07-31 05:25:36 +02:00
# assemble a keyphrase out of all params passed to the script
keyphrase = ' '.join(sys.argv[1:])
# create a dictionary of cheatsheets
cheatsheets = {
2013-07-31 04:48:07 +02:00
2013-07-31 05:57:04 +02:00
########## dhclient ##########################################################
'dhclient' : '''
@todo
''',
########## find ##############################################################
2013-07-31 04:48:07 +02:00
'find' : '''
2013-07-31 05:25:36 +02:00
executable perms
file not directory
directory not file
2013-07-31 04:48:07 +02:00
''',
2013-07-31 05:57:04 +02:00
########## git ###############################################################
2013-07-31 04:48:07 +02:00
'git' : '''
To set your identify:
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
To enable color:
git config --global color.ui true
''',
2013-07-31 05:57:04 +02:00
########## ifconfig ##########################################################
'ifconfig' : '''
@todo
''',
########## ln ################################################################
2013-07-31 04:48:07 +02:00
'ln' : '''
To create a symlink:
2013-07-31 05:57:04 +02:00
@todo
2013-07-31 04:48:07 +02:00
''',
2013-07-31 05:57:04 +02:00
########## ssh ###############################################################
'ssh' : '''
To execute a command on a remote server:
@todo
''',
########## tar ###############################################################
2013-07-31 04:48:07 +02:00
'tar' : '''
To extract an uncompressed archive:
tar -xvf /path/to/foo.tar
2013-07-31 05:57:04 +02:00
To extract a .gz archive:
2013-07-31 04:48:07 +02:00
tar -xzvf /path/to/foo.tgz
2013-07-31 05:57:04 +02:00
To create a .gz archive:
2013-07-31 04:48:07 +02:00
tar -czvf /path/to/foo.tgz /path/to/foo/
2013-07-31 05:57:04 +02:00
To extract a .bz2 archive:
2013-07-31 04:48:07 +02:00
tar -xjvf /path/to/foo.tgz
2013-07-31 05:57:04 +02:00
To create a .bz2 archive:
2013-07-31 04:48:07 +02:00
tar -cjvf /path/to/foo.tgz /path/to/foo/
''',
2013-07-31 05:57:04 +02:00
########## x #################################################################
'x' : '''
To tunnel an X application over SSH:
@todo
''',
2013-07-31 04:48:07 +02:00
}
# print help if requested
2013-07-31 05:57:04 +02:00
if keyphrase in ['', 'help', '--help', '-h']:
print 'Usage: cheat [keyphrase]'
print 'Available keyphrases:'
for key in cheatsheets:
2013-07-31 05:25:36 +02:00
print key
exit()
# print the cheatsheet if it exists
2013-07-31 05:57:04 +02:00
# @todo: if I could get tab-completion on the cheatsheet names, that would
# be awesome
print cheatsheets[keyphrase] if keyphrase in cheatsheets.keys() else 'No cheatsheet found.'