mirror of
https://github.com/Erreur32/cheat.git
synced 2024-12-22 21:52:12 +01:00
58 lines
1.1 KiB
Python
Executable file
58 lines
1.1 KiB
Python
Executable file
#!/usr/bin/env python
|
|
import sys
|
|
|
|
# assemble a keyphrase out of all params passed to the script
|
|
keyphrase = ' '.join(sys.argv[1:])
|
|
|
|
# Create a dictionary of cheatsheets
|
|
cheats = {
|
|
|
|
'find' : '''
|
|
executable perms
|
|
file not directory
|
|
directory not file
|
|
''',
|
|
|
|
'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
|
|
''',
|
|
|
|
'ln' : '''
|
|
To create a symlink:
|
|
@todo: complete this
|
|
''',
|
|
|
|
'tar' : '''
|
|
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/
|
|
''',
|
|
|
|
}
|
|
|
|
# Print help if requested
|
|
if keyphrase == 'help' or keyphrase == '--help' or keyphrase == '-h':
|
|
print 'Cheatsheets exist for the following keyphrases:'
|
|
for key in cheats:
|
|
print key
|
|
exit()
|
|
|
|
|
|
# Print the cheatsheet if it exists
|
|
print cheats[keyphrase] if keyphrase in cheats.keys() else 'No cheatsheet found.'
|