1
0
mirror of https://github.com/cheat/cheat.git synced 2025-05-16 05:06:05 +02:00

Compare commits

...

406 Commits

Author SHA1 Message Date
Chris Allen Lane
7908a678df
Merge pull request from cheat/dependabot/go_modules/github.com/cloudflare/circl-1.3.7
chore(deps): bump github.com/cloudflare/circl from 1.3.6 to 1.3.7
2024-01-08 15:34:48 -05:00
dependabot[bot]
7c0eacb53d
chore(deps): bump github.com/cloudflare/circl from 1.3.6 to 1.3.7
Bumps [github.com/cloudflare/circl](https://github.com/cloudflare/circl) from 1.3.6 to 1.3.7.
- [Release notes](https://github.com/cloudflare/circl/releases)
- [Commits](https://github.com/cloudflare/circl/compare/v1.3.6...v1.3.7)

---
updated-dependencies:
- dependency-name: github.com/cloudflare/circl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-08 16:53:49 +00:00
Chris Allen Lane
4bf804ac60
Merge pull request from cheat/dependabot/go_modules/golang.org/x/crypto-0.17.0
chore(deps): bump golang.org/x/crypto from 0.16.0 to 0.17.0
2023-12-19 14:51:50 -05:00
dependabot[bot]
33c5918087
chore(deps): bump golang.org/x/crypto from 0.16.0 to 0.17.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.16.0 to 0.17.0.
- [Commits](https://github.com/golang/crypto/compare/v0.16.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-19 00:07:38 +00:00
Christopher Allen Lane
d34177729d chore: bump version to 4.4.2 2023-12-15 12:48:39 -05:00
Chris Allen Lane
7fa50328d7
Merge pull request from chrisallenlane/chroma
chore(deps): bump chroma to v2 
2023-12-13 12:59:52 -05:00
Christopher Allen Lane
1790aec85d chore(deps): bump chroma to v2
Bump `alecthomas/chroma` to `v2`:
https://github.com/cheat/cheat/issues/735
2023-12-13 12:54:32 -05:00
Mikel Olasagasti Uranga
6bf51e758f Use yaml.v3 rather than .v2 and .v1 2023-12-13 09:57:58 -05:00
Christopher Allen Lane
242da8c89a chore(build): remove plan9 support
Remove `plan9` support from the `Makefile` because the executable now
fails to build.
2023-12-13 09:45:21 -05:00
Chris Allen Lane
2294f40ee0
Merge pull request from chrisallenlane/v4.4.1
V4.4.1
2023-12-13 09:17:16 -05:00
Christopher Allen Lane
fe25019b14 chore: bump version to 4.4.1 2023-12-13 09:12:14 -05:00
Christopher Allen Lane
bfb071c0b2 chore(lint): various changes to appease revive
- Add `package` comments
- Rename `opts` to `_` where unused
2023-12-13 09:10:20 -05:00
Christopher Allen Lane
95a4e31b6c chore(deps): upgrade dependencies
Upgrade all dependencies to newest versions.
2023-12-13 08:29:02 -05:00
Chris Allen Lane
0d9c92c8c0
Merge pull request from chrisallenlane/v4.4.0
V4.4.0
2022-11-05 13:11:22 -04:00
Christopher Allen Lane
16c50bb659 chore: bump version to 4.4.0 2022-11-05 12:56:43 -04:00
Christopher Allen Lane
1a85c9e9c8 feat: platform compatibility
Add experimental support for the following platforms:

- aix
- dragonfly
- illumos
- ios
- netbsd
- openbsd
- plan9
- solaris
2022-11-05 12:00:43 -04:00
Christopher Allen Lane
c9ccefa607 chore(deps): remove yaml.v1
Remove errant `yaml.v1` dependency, and use `yaml.v2` everywhere.
2022-11-05 11:39:48 -04:00
Christopher Allen Lane
3a6b6e58f0 chore(deps): update dependencies
`make vendor-update`
2022-11-05 10:15:15 -04:00
Christopher Allen Lane
2edc0ee299 chore: add a comment
Add a small comment regarding a tricky edge-case in `gitdir.go`.
2022-08-28 06:54:29 -04:00
Chris Allen Lane
bd9fa1ba70
Merge pull request from chrisallenlane/4.3.3
4.3.3
2022-08-27 22:07:19 -04:00
Christopher Allen Lane
bb85e611f4 chore: bump version to 4.3.3 2022-08-27 21:29:06 -04:00
Christopher Allen Lane
a2f538f114 refactor(repo): create repo package
- Refactor `installer.clone` into new `repo.Clone` package and method.

- Refactor `sheets.isGitDir` into `repo.GitDir`.

Both of these changes read better, and will facilitate cleaner
architecture when `--update` is implemented.
2022-08-27 21:02:48 -04:00
Christopher Allen Lane
80c91cbdee feat(installer): use go-git to clone
Integrate `go-git` into the application, and use it to `git clone`
cheatsheets when the installer runs.

Previously, the installer required that `git` be installed on the system
`PATH`, so this change has to big advantages:

1. It removes that system dependency on `git`
2. It paves the way for implementing the `--update` command

Additionally, `cheat` now performs a `--depth=1` clone when installing
cheatsheets, which should at least somewhat improve installation times
(especially on slow network connections).
2022-08-27 21:00:46 -04:00
Christopher Allen Lane
ede2d2dbaa fix(Sheets): .gitignore in cheatpath ()
Fix an issue whereby `cheat` would crash if a cheatpath contained a file
that began with `.git`, like `.gitignore`.
2022-08-27 20:57:07 -04:00
Chris Allen Lane
db3d7e53a4
Merge pull request from chrisallenlane/4.3.2
4.3.2
2022-08-26 14:07:14 -04:00
Christopher Allen Lane
06c4ff52fc chore: bump version to 4.3.2 2022-08-26 13:56:35 -04:00
Christopher Allen Lane
cbc2638d96 fix(docopt): whitespace typo in --help output
Fix a whitespace (alignment) typo in the `--help` output.
2022-08-26 13:56:35 -04:00
Christopher Allen Lane
fd93da799d fix(sheets): cheatsheets in submodules ()
Resolve an issue whereby cheatsheets contained within `git` submodules
were ignored due to a regression introduced in `4.3.1`.
2022-08-26 13:55:09 -04:00
Christopher Allen Lane
5c5ed7344f chore(docs): improve configuration docs ()
Improve the configuration documentation in `configs/conf.yml` ().
2022-08-26 13:55:09 -04:00
Christopher Allen Lane
d773383f70 fix(build): Makefile corrections
- Fix an issue whereby `make clean` filed to remove assets created by
  `make generate`.

- Fix a subsequent issue whereby `make generate` was being run too late
  in the `make build` target, which resulted in a build failure.
2022-08-26 13:55:09 -04:00
Christopher Allen Lane
2717044b62 chore(docs): update INSTALLING.md ()
Update `INSTALLING.md` with more package information. See: 
2022-08-26 13:55:09 -04:00
Christopher Allen Lane
2d635293c5 refactor(Sheet): create parse method
Move `Frontmatter.Parse` to `Sheet.parse`, and delete the `frontmatter`
package. `Sheet.parse` more accurately describes the parser's behavior.
2022-08-26 13:55:09 -04:00
Christopher Allen Lane
f0bfeda47a fix(frontmatter): do not trim whitespace ()
Do not strip leading or trailing newlines. Doing so had interferred with
users' intended cheatsheet layouts.
2022-08-26 13:55:09 -04:00
Christopher Allen Lane
f1540290a7 chore(deps): update dependencies 2022-08-26 11:06:21 -04:00
Chris Allen Lane
0b80a608c3
Merge pull request from chrisallenlane/4.3.1
4.3.1
2022-08-08 21:01:56 -04:00
Christopher Allen Lane
3c1e24a0e8 chore: bump version to 4.3.1 2022-08-08 20:38:23 -04:00
Christopher Allen Lane
2a6586b41b fix(installer): always use more pager on Windows 2022-08-08 20:38:23 -04:00
Christopher Allen Lane
6421953183 feat(installer): set default editor
Attempt to set and locate a default editor when running the installer.
2022-08-08 20:14:27 -04:00
Christopher Allen Lane
0c47f44ff9 fix: no colorization on default install ()
Fix an issue whereby a default installation (as created by the
installer) would (seemingly) fail to output colorized text, even when
the `-c` flag was passed.

The root cause of the problem was that the installer did not set a
default `style` for `chroma`, which in turn defaulted to using the `bw`
(black-and-white) style.

Thus, colorization actually *was* being applied with `-c` - it was
simply black and white!
2022-08-08 19:45:32 -04:00
Christopher Allen Lane
77f9c3fdd0 fix(Sheets): cheatsheets in hidden directories ()
Fix an issue whereby cheatsheets that were contained within hidden
directories were prevented from being loaded.
2022-08-08 19:17:59 -04:00
Chris Allen Lane
b53a14b1a7
Merge pull request from chrisallenlane/4.3.0
4.3.0
2022-08-07 14:45:27 -04:00
Christopher Allen Lane
f1e8602369 chore: bump version to 4.3.0 2022-08-07 14:11:47 -04:00
Christopher Allen Lane
ddbe710881 feat: add the --conf command
Add the `--conf` command, which dipslay's the current `cheat`
configuration file path.
2022-08-07 14:08:25 -04:00
Christopher Allen Lane
d598d96fce fix(Config): colorization without pager ()
Fix an issue whereby colorization would output ANSI codes if a pager was
not configured.

The solution here is to stop guessing about the state of the user's
system at runtime, as well as the user's intention. The installer now
chooses an appropriate installer when generating configs, and no longer
bothers searching for pagers at runtime.
2022-08-07 10:19:56 -04:00
Christopher Allen Lane
4fdec50487 chore(deps): upgrade dependencies
- Upgrade to Go 1.19 in `go.mod`
- Upgrade dependencies
2022-08-07 10:19:56 -04:00
Chris Allen Lane
9de866dfb6
Merge pull request from chrisallenlane/ci
chore(ci): YAML lints
2022-08-05 07:53:53 -04:00
Christopher Allen Lane
eb99a070ce chore: CI template nits
- Fix YAML nits per `yamllint`
- Upgrade Go version to `1.19`
2022-08-05 07:49:20 -04:00
Chris Allen Lane
73f80bde48
Merge pull request from chrisallenlane/4.2.7
4.2.7
2022-08-05 07:01:51 -04:00
Chris Allen Lane
8130b2f3bd chore: bump version to 4.2.7 2022-08-05 06:41:16 -04:00
Christopher Allen Lane
f4e6c76e58 fix: escape sequences in search output ()
Fix an issue whereby ANSI escape characters could appear in search
output when a pager was not configured.

The root cause of the problem was code that was overzealously applying
an underlying effect to search terms.

This commit simply rips out underlying entirely, both as means of
resolving this problem, and also simply for removing needless visual
noise from search output.
2022-08-05 06:41:16 -04:00
Chris Allen Lane
85f5ae8ec7 chore: various lint corrections
Make various lint corrections in order to appease `staticcheck`.
2022-08-04 20:43:50 -04:00
Chris Allen Lane
484b447391 perf(Sheets): do not walk hidden directories
Modify `Sheets.Load` to not walk hidden directories like `.git`. This
optimization can potentially prevent thousands of system calls from
being made, because `.git` directories can contain many files.
2022-08-04 20:43:42 -04:00
Chris Allen Lane
cfd1702bc6
Merge pull request from chrisallenlane/page-bug
Fix 
2022-08-02 20:37:48 -04:00
Christopher Allen Lane
7406ebfb5e chore(deps): update dependencies 2022-08-02 20:30:31 -04:00
Christopher Allen Lane
0737af2fec fix: pagination error on Linux
Bury the `more` pager default on Linux in an effort to work around the
following problem:

https://github.com/cheat/cheat/issues/681#issuecomment-1201842334

We're satisficing for this kludge because it does not appear to be
possible to actually make `more` perform as expected in all
environments.
2022-08-02 20:27:56 -04:00
Christopher Allen Lane
a23d372d1f docs(INSTALLING): nix link
Update the `nix` package information.
2022-07-06 08:11:42 -04:00
Chris Allen Lane
fe66ff3768
Merge pull request from chrisallenlane/hacking-md
docs: create `HACKING.md`
2022-07-05 15:11:09 -04:00
Christopher Allen Lane
7fed1f63a6 docs: create HACKING.md
Create a `HACKING.md` file for onboarding new developers to `cheat`.
2022-07-05 15:07:34 -04:00
Christopher Allen Lane
a297d1619c chore(build): remove make docker-run
Remove the `docker-run` `make` target, which was added in haste. It was
entirely redundant with `docker-sh`.
2022-07-05 14:40:15 -04:00
Chris Allen Lane
ef1da90a77
Merge pull request from chrisallenlane/go-install
Build/CI corrections
2022-07-05 12:24:48 -04:00
Christopher Allen Lane
d8f405c112 chore(ci): use Go 1.18 in CI
Use Go 1.18 in the CI pipeline.
2022-07-05 11:59:08 -04:00
Chris Allen Lane
f8403ff241
Merge pull request from chrisallenlane/install-md
docs: create `INSTALLING.md`
2022-07-05 11:24:02 -04:00
Christopher Allen Lane
65f6be3fd8 docs: create INSTALLING.md
- Create `INSTALLING.md`
- Update the `README.md`
2022-07-05 11:19:40 -04:00
Chris Allen Lane
1cb53697d2
Merge pull request from cheat/4.2.5
4.2.5
2022-07-04 22:37:19 -04:00
Christopher Allen Lane
14f321b0e6 chore: bump version to 4.2.5 2022-07-04 22:00:35 -04:00
Christopher Allen Lane
d3250fda79 chore(deps): upgrade vendored dependencies 2022-07-04 22:00:35 -04:00
Zhizhen He
c482488c41 fix: replace Parse with ParseArgs
Parse() is deprecated
2022-07-04 22:00:35 -04:00
Chris Allen Lane
fe8f39013e
Merge pull request from chrisallenlane/win-compat
fix: Windows compatibility
2022-07-04 17:03:11 -04:00
Christopher Allen Lane
1016b20ef2 chore: bump version to 4.2.4
Bump version to `4.2.4`. This version contains numerous Windows fixes
and improvements.
2022-07-04 16:58:58 -04:00
Christopher Allen Lane
def8985dcd fix: Windows support
Fix an issue whereby the installer installed cheatsheets into the wrong
directory on Windows. This occurred because previously `path.Join` was
used where `path/filepath.Join` should have been used.

This matters, because the former always uses `/` as the path separator,
whereas the latter will use `/` or `\` as is appropriate for the
runtime environment.

This should resolve bullet point 4 in .
2022-07-04 16:55:57 -04:00
Christopher Allen Lane
e6f12147df fix: config fixes for Windows
- Update the default config file to use `more` instead of `less` as the
  default pager, in order to support Windows out-of-the-box. (, ).

- Use `terminal` Chroma formatter (rather than `terminal16m`) in order
  to accommodate less capable terminal emulators like `cmd.exe` by
  default. Similarly, default to `colorize: false` in configs (changed
  from `true`) ().

- Comment out default `style` in order to avoid printing ANSI color
  codes into terminals without color support ()

- Attempt to intelligently choose a default editor, rather than rely on
  a hard-coded `vim` in the configs. This should make it easier to use
  `cheat` immediately without needing to specify configs. It should also
  improve `cheat`'s Windows compatibility. ()
2022-07-04 16:06:37 -04:00
Christopher Allen Lane
a8c2c396ed feat(build): crate docker-run target
Create a `docker-run` `make` target for opening a shell in an Alpine
container for development.
2022-07-04 13:13:27 -04:00
Christopher Allen Lane
35262df4f2 fix(build): Windows executable packaging
Fix an issue whereby the Windows zip release contained an extraneous
(and annoying) `dist` parent directory.
2022-07-04 12:34:06 -04:00
Chris Allen Lane
12ffa4cb5c
Merge pull request from cheat/develop
Windows fixes, Android support
2021-10-09 12:13:01 -04:00
Chris Allen Lane
d9c602f9e1
Merge pull request from chrisallenlane/android
fix(Paths): Android support
2021-10-09 11:30:18 -04:00
Christopher Allen Lane
b67ff8b6a8 fix(Paths): Android support
Add `"android"` to the explicit whitelist of supported operating
systems.  This may resolve incompatibilities with certain Android
environments.
2021-10-09 11:27:38 -04:00
Christopher Allen Lane
a500a621a1 chore: bump version
Bump version to 4.2.3.
2021-10-09 10:59:02 -04:00
Chris Allen Lane
23b6928874
Merge pull request from mattn/fix-windows
Fix Windows
2021-10-09 10:10:39 -04:00
Chris Allen Lane
9de39fb12b
Merge pull request from cheat/dependabot/go_modules/github.com/mattn/go-isatty-0.0.14
chore(deps): bump github.com/mattn/go-isatty from 0.0.13 to 0.0.14
2021-10-09 09:51:49 -04:00
Chris Allen Lane
ad501c4cbe
Merge pull request from OmgImAlexis/patch-1
chore: fix typo in comment
2021-10-09 09:39:41 -04:00
Christopher Allen Lane
f17de401e5 docs(CONTRIBUTING): pr against develop
Add a note to `CONTRIBUTING.md` requesting that contributors open
pull-requests against the `develop` branch.
2021-10-09 09:34:23 -04:00
Alexis Tyler
2c097adeda
chore: fix typo in comment 2021-09-30 07:30:20 +09:30
Yasuhiro Matsumoto
b825e0f535
Fix Windows 2021-09-29 01:33:59 +09:00
dependabot[bot]
8385277b28
chore(deps): bump github.com/mattn/go-isatty from 0.0.13 to 0.0.14
Bumps [github.com/mattn/go-isatty](https://github.com/mattn/go-isatty) from 0.0.13 to 0.0.14.
- [Release notes](https://github.com/mattn/go-isatty/releases)
- [Commits](https://github.com/mattn/go-isatty/compare/v0.0.13...v0.0.14)

---
updated-dependencies:
- dependency-name: github.com/mattn/go-isatty
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-07 22:10:46 +00:00
Chris Lane
768d55e5d4 chore: bump version
Bump version to `4.2.2`.
2021-06-08 21:02:03 -04:00
Chris Lane
6aedc5c116 chore: whitespace edit on Makefile 2021-06-08 20:59:57 -04:00
Chris Lane
e881bb1f97 chore: update go.sum 2021-06-08 20:59:57 -04:00
Chris Lane
501f9c66ad deps: upgrade dependencies 2021-06-08 20:59:57 -04:00
Pablo Lecolinet
a2aa82d9f3 Add ARM64/ARMv8 build 2021-06-08 20:59:57 -04:00
PabloLec
018bce7ad5 Fix ZSH autocompletion 2021-06-07 11:42:47 +02:00
Chris Allen Lane
17acefdd9b
Merge pull request from bernermic/master
Adds some git helper scripts
2021-05-14 12:21:26 -04:00
Michael Berner
37918e09a4
Adds some git helper scripts 2021-05-07 20:53:54 +02:00
Chris Allen Lane
86967873a8 Merge pull request from cheat/github-actions
chore: migrate into Github Actions
2021-05-03 17:02:27 -04:00
Chris Lane
d237d98c15 chore: migrate into Github Actions
Replace Travis CI integration in favor of Github Actions.
2021-05-03 16:43:27 -04:00
Chris Allen Lane
eb9b3e7798
Merge pull request from cheat/dependabot/add-v2-config-file
chore: upgrade to GitHub-native Dependabot
2021-05-03 14:32:08 -04:00
dependabot-preview[bot]
b0a351033d
Upgrade to GitHub-native Dependabot 2021-04-29 20:40:56 +00:00
Chris Allen Lane
1eb44e8809
Merge pull request from chrisallenlane/v4.2.1
Squashed commit of the following:
2021-04-28 12:55:17 -04:00
Chris Lane
55b18b4897 Squashed commit of the following:
commit 95479c8ad744db48386a5c78e54ef8da80e9120b
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Wed Apr 28 12:26:32 2021 -0400

    chore(version): bump version to 4.2.1

commit 6956f51caea74cef7a09a39c3e4d5bcb66d4b2c5
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Wed Apr 28 12:24:21 2021 -0400

    fix(Makefile): `vendor-update`

    Update the `vendor-update` build target to run `go mod vendor` after
    updating dependencies.

commit 0aca411279e06d8b9edfc9c25f0b9d03ea028de7
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Wed Apr 28 12:23:24 2021 -0400

    chore(deps): update dependencies

commit e847956b020d2709f1f5625f2d500733e26872c0
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Wed Apr 28 08:26:51 2021 -0400

    chore(deps): build updates

    - Upgrade `go` to `1.16.3`

    - Attempt to fix build errors regarding dependencies
2021-04-28 12:35:32 -04:00
Chris Allen Lane
883a17092f
Merge pull request from chrisallenlane/4.2.0
4.2.0
2020-11-28 11:27:09 -05:00
Chris Lane
4f2a57fce8 fix(view): whitespace corrections
- Fix bug whereby `--all` flag would conflict with pager

- Fix whitespace inconsistencies among view and search outputs
2020-11-28 11:18:16 -05:00
Chris Lane
ecc96c64f9 refactor(installer): externalize installer
Move installation-related code out of `main.go` and into a new
`installer.Run` method.
2020-11-28 10:32:37 -05:00
Chris Lane
a81dd96ff4 fix: rename display.go
Rename `display.go` to `write.go`. (I forgot to do this previously.)
2020-11-27 23:05:02 -05:00
Chris Lane
fb538baba5 chore(version): bump to 4.2.0 2020-11-27 22:57:25 -05:00
Chris Lane
1a7b5c6127 feat(display): make Faint respect Colorize
Make `display.Faint` respect the `Colorize` config value.
2020-11-27 22:50:55 -05:00
Chris Lane
cdddfbb516 chore: rename display.Display
Rename `display.Display` to `display.Write` for clarity and to reduce
"stutter".
2020-11-27 22:35:24 -05:00
Chris Lane
4ef4c35d8c feat(search): search all cheatpaths
Update the search function. It now searches all cheatpaths all the time,
as if `--all` were implicitly passed.
2020-11-27 22:31:16 -05:00
Chris Lane
a58294859e chore: spelling
`s/pathSheets/pathsheets/g` in `cmd_list` for consistency elsewhere.
2020-11-27 22:26:14 -05:00
Chris Lane
606092e288 feat(search): improve search output formatting
Improve the search output formatting.
2020-11-27 17:06:02 -05:00
Chris Lane
233a9de1aa feat: implement --all flag
Implement an `--all` flag that can be used to view cheatsheets on all
chaetpaths. (Resolves )
2020-11-27 16:39:34 -05:00
Chris Lane
aa16f68620 feat(display): add methods to display
- Add `indent`, `faint`, and `underline` methods to `display`
- Add tests for the above
2020-11-27 16:14:33 -05:00
Chris Lane
367673d5d9 chore(dependencies): update dependencies
Run `make vendor-update`.
2020-11-27 09:51:39 -05:00
Chris Lane
08fb9e11a9 feat(Makefile): add vendor-update
Add `vendor-update` target to `Makefile`, which updates all dependencies
to their newest versions.
2020-11-27 09:50:11 -05:00
Chris Lane
3f4d4bddb2 feat(tests): add unit-tests
Add unit-tests for `sheets.Load`.
2020-11-11 19:33:31 -05:00
Chris Allen Lane
6c6753b35c
Merge pull request from chrisallenlane/issue-597
fix: update installation instructions in README
2020-11-07 18:56:37 -05:00
Chris Lane
0718b606e1 fix(README): clarify installation verbiage
Update the installation verbiage in the `README` for clarity
(issue ).
2020-11-07 18:48:24 -05:00
Chris Lane
857119b443 feat(Docker): create development Docker image
- Create Docker image to be used for experimentation during development
- Create targets in `Makefile` pertaining to the above
2020-11-07 18:47:24 -05:00
Chris Allen Lane
f421483eea
Merge pull request from chrisallenlane/v4.1.1
v4.1.1
2020-11-03 18:32:25 -05:00
Chris Lane
4adddbf504 chore: bump version to v4.1.1 2020-11-03 18:05:46 -05:00
Chris Lane
b9c86b6975 chore(dependencies): update dependencies 2020-11-03 17:59:56 -05:00
Chris Lane
0b21ccf6f8 feat(tests): improve test coverage 2020-11-03 17:29:49 -05:00
Chris Allen Lane
a3ad8c5101
Merge pull request from chrisallenlane/codeql
feat: integrate CodeQL build action
2020-11-01 10:51:38 -05:00
Chris Lane
bacb74929a feat: integrate CodeQL build action 2020-11-01 10:47:25 -05:00
Chris Allen Lane
82e1c27494
Merge pull request from chrisallenlane/bare-tag
feat: implement `cheat -t` shorthand
2020-09-05 09:05:09 -04:00
Chris Lane
45beeb2edb chore: bump version to 4.1.0 2020-09-05 08:56:51 -04:00
Chris Lane
c2c479b36c feat: support -t shorthand
Make `cheat -t <tag>` function as a shorthand for `cheat -l -t <tag>`.
2020-09-02 17:17:44 -04:00
Chris Allen Lane
cb0243e7fc
Merge pull request from ryaanwells/patch-1
Fixing "cheetsheet" typo in README.md
2020-08-23 15:25:55 -04:00
Ryan Wells
e5d04d41ea
Fixing "cheetsheet" typo in tags_test.go 2020-08-21 15:45:49 +01:00
Ryan Wells
2474ea4fb1
Fixing "cheetsheet" typo in README.md 2020-08-18 14:53:15 +01:00
Chris Allen Lane
7467c9fbc0
Merge pull request from chrisallenlane/v4.0.3
chore: update dependencies
2020-08-08 13:45:10 -04:00
Chris Lane
dfba3da003 chore: update dependencies 2020-08-08 10:29:29 -04:00
Chris Allen Lane
ad7ad64a75
Merge pull request from chrisallenlane/linux-conf
fix(config): add /etc/cheat config path
2020-07-11 08:12:04 -04:00
Chris Lane
c4dcfd5da0 fix(config): add /etc/cheat config path
Add `/etc/cheat/conf.yml` to default config paths. See  for context.
2020-07-09 18:28:10 -04:00
Chris Allen Lane
278a5d9154
Merge pull request from cheat/v4.0.1
fix(search): fix pagination error
2020-06-30 07:26:30 -04:00
Chris Lane
9fa0c466fd fix(search): fix pagination error
Fix the paginator when used in combination with the `-s` (search)
subcommand. Previously, it would not behave as intended, because `cheat`
was writing to `stdout` at inappropriate times.
2020-06-30 07:21:21 -04:00
Chris Allen Lane
4e9b2928b3
Merge pull request from chrisallenlane/dev
v4.0.0
2020-06-25 19:05:37 -04:00
Chris Lane
fa5eb44be8 chore: bump version to 4.0.0 2020-06-25 18:53:27 -04:00
Chris Lane
49afd7c16b feat: modify return codes
Modify exit codes. `cheat` now returns an exit code value `2` on errors
pertaining to a cheatsheet not being found.

BREAKING CHANGE
2020-06-25 18:38:03 -04:00
Chris Lane
59d5c96c24 feat(pagination): implement paginated output
Implement a `pager` config option. If configured, `cheat` will
automatically pipe output through the configured pager (where
appropriate).
2020-06-25 18:21:51 -04:00
Chris Allen Lane
8e602b0e93
Merge pull request from chrisallenlane/3.10.1
feat(makefile): support 32-bit systems
2020-05-14 20:11:14 -04:00
Chris Lane
fb04cb1fcd feat(makefile): support 32-bit systems
- Update the `Makefile` to additionally output a 386 binary ()
- Update the dependencies ()
- Bump version
2020-05-14 20:02:35 -04:00
Chris Allen Lane
d42726101e
Merge pull request from cheat/3.10.0
3.10.0
2020-05-11 20:20:09 -04:00
Chris Lane
93b3a711f5 chore: bump version to 3.10.0 2020-05-11 20:15:26 -04:00
Chris Lane
9c3d41c8bd Merge branch 'syohex-syohex/improve-completion' into 3.10.0 2020-05-11 20:13:58 -04:00
Chris Lane
4eeec6c868 chore(deps): resolve dependency conflict 2020-05-11 20:12:28 -04:00
dependabot-preview[bot]
1b17ab1914
chore(deps): bump github.com/alecthomas/chroma from 0.7.1 to 0.7.3
Bumps [github.com/alecthomas/chroma](https://github.com/alecthomas/chroma) from 0.7.1 to 0.7.3.
- [Release notes](https://github.com/alecthomas/chroma/releases)
- [Changelog](https://github.com/alecthomas/chroma/blob/master/.goreleaser.yml)
- [Commits](https://github.com/alecthomas/chroma/compare/v0.7.1...v0.7.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-11 07:20:59 +00:00
Shohei YOSHIDA
477650ee44 Improve zsh completion 2020-04-12 11:03:08 +09:00
Chris Allen Lane
c4dd3b52fd
Merge pull request from chrisallenlane/master
v3.9.0
2020-04-07 18:59:18 -04:00
Chris Lane
e8a0ea0dc3 chore(version): bump version to 3.9.0 2020-04-07 18:50:00 -04:00
Chris Lane
992ee66a56 Merge branch 'add-homebrew-release-flow' of https://github.com/chenrui333/cheat into v3.9.0 2020-04-07 18:48:57 -04:00
Chris Lane
c9840c2d6f docs(autocompletion): update autocompletion docs
Update the autocompletion documentation (in `README` and `man` page) to
include information about configuring `zsh` autocompletion script.
2020-04-07 18:47:35 -04:00
Chris Lane
bd53768f67 chore(zsh): set execute perm on cheat.zsh
Set execute permission on the `zsh` autocompletion script.
2020-04-07 18:41:00 -04:00
raochsinai
8092687956 change taglist and pathlist to local variable. 2020-04-07 14:56:34 +08:00
raochsinai
16ade50672 add complete script for zsh. 2020-04-03 15:34:01 +08:00
Rui Chen
62c80d76eb
Automate homebrew release flow 2020-03-24 21:21:54 -04:00
Chris Allen Lane
3e67eaa3b7
Merge pull request from chrisallenlane/issue-272
docs(man): implement manpage
2020-03-24 20:55:57 -04:00
Chris Lane
38b13655fe chore(version): bump version to 3.8.0 2020-03-24 20:54:40 -04:00
Chris Lane
749d5c1182 docs(man): implement manpage
- Implement `make man` to generate a manpage

- Change verb tense in `make` help text
2020-03-24 20:46:48 -04:00
Chris Allen Lane
521f83377c
Merge pull request from chrisallenlane/issue-544
fix(frontmatter): resolve 
2020-03-11 19:03:06 -04:00
Chris Lane
b15ff10537 chore(version): bump version to 3.7.1 2020-03-11 18:55:59 -04:00
Chris Lane
5288bd0c1c fix(frontmatter): resolve issue
- Fix error in `frontmatter.Parse` which would cause a `panic` when
  encountering malformed frontmatter

- Add a unit-test to cover the above
2020-03-11 18:54:46 -04:00
Chris Lane
bddbee4158 fix(logging): improve sheets load logging
Improve logging in `sheets.Load`:

- Make error verbage consistant with verbiage elsewhere

- Add more information to logging statements
2020-03-11 18:51:06 -04:00
Chris Lane
ce27cf2cc0 chore(version): bump version to 3.7.0 2020-03-06 20:19:31 -05:00
Chris Lane
5733b1d6d4 chore(vendor): update vendor dependencies 2020-03-06 20:18:41 -05:00
Chris Lane
2d221050d8 Merge branch '1-14' into 3.7.0 2020-03-06 20:17:54 -05:00
Chris Lane
ce37b670c7 feat(installer): implement "installer"
Squashed commit of the following:

commit 5c322e79b7b6fa6bef51cac2f9b03fe2eaf08163
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Fri Mar 6 19:56:56 2020 -0500

    docs(README): update the `README`

    Update the `README` to document the improved config-generation
    mechanism.

commit 803e1f014cc89c30bfb80549b64195235b8b9f62
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Fri Mar 6 19:19:49 2020 -0500

    feat(config-init): platform-specific pathing

    Update `--init` subcommand to rely upon the same platform-detection
    intelligence that was previously implemented by the "installer".

    The installer and `--init` should now produce identical config files.

commit 99c48097e2e23755710d08a099918675895192f7
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Fri Mar 6 18:26:33 2020 -0500

    feat(installer): platform-correct config templating

    Modify the "installer" to populate cheatpaths with sensible defaults
    based on the detection of the user's operating system and environment.

commit 8e1580ff5a30ae3241c3f02b806666583c5d44b2
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Thu Mar 5 20:19:58 2020 -0500

    fix(tests): fix `config.Paths` tests

    Refactor `config.Paths` (by externalizing a call to `homedir.Dir`) to
    decouple it from filesystem paths, thus facilitating cleaner unit-tests.

commit a08dca70d90bb6d568d44abf76b2bd911d929001
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Thu Mar 5 18:14:27 2020 -0500

    feat(installer): default path selection

    Modify the installer to improve default config and cheatsheet path
    selection.

commit e15bc6c966bfdca3b507504c95a34b74e264be11
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Thu Mar 5 17:49:50 2020 -0500

    fix(typo): correct comment typo in `main.go`

commit efd09575df4422449d6178cd922a680e0f871c21
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Thu Mar 5 17:46:49 2020 -0500

    feat(config): refactor config path detection

    Previously, failing other checks, on Unix and BSD systems,
    `config.Paths` would attempt to compute the user's home directory by
    reading the `HOME` environment variable.

    This change deprecates that approach with a call to `homedir.Dir`, which
    is used elsewhere throughout the application.

commit ec10244ebeb2a48e5c694aeabb8bcbc177a77369
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Thu Mar 5 17:15:28 2020 -0500

    chore(installer): delete unused file

    Delete `installer/installer.go`, which (in hindsight) was unnecessary.

commit ebd9ec62873d7f286586ea0af9113d74b8a1d2f2
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Wed Mar 4 19:31:13 2020 -0500

    wip(installer): stub experimental "installer"

    Stubs out an experimental "installer" that will help new users to
    quickly configure `cheat`.

commit ecac5a09717a4a4714637946d3699da5db97fcc7
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Wed Mar 4 19:30:12 2020 -0500

    chore(dependencies): updates vendored dependencies
2020-03-06 20:17:26 -05:00
Rui Chen
47a9eeb4fd go mod vendor 2020-03-03 18:28:13 -05:00
Rui Chen
be56c9cf0c Bump golang to v1.14 2020-03-03 18:27:31 -05:00
Chris Allen Lane
7be57cb01c
Merge pull request from chrisallenlane/master
fix: README and Makefil
2020-02-26 19:29:04 -05:00
Chris Lane
8453af8601 fix(Makefile): build targets
Adds missing dependencies to the `build` and `install` targets.
2020-02-26 19:21:07 -05:00
Chris Lane
6e388c3693 fix(README): typo fix
Fixes a bad link to the completion scripts in the `README`.
2020-02-26 19:20:24 -05:00
Chris Allen Lane
b13246978a
Merge pull request from chrisallenlane/improved-search
feat(search): issue 
2020-02-15 18:07:40 -05:00
Chris Lane
a39d36cd34 chore: bumps version to 3.6.0 2020-02-15 16:13:33 -05:00
Chris Lane
87cba04ff2 chore: DRY out colorization code
Creates a `sheet.Colorize` method that DRYs out code that was duplicated
among `cmd_search` and `cmd_view`.
2020-02-15 16:11:15 -05:00
Chris Lane
bc623da74b feat: issue
Dramatically improves the usefulness of `--search` by outputting
"chunked" results. This removes the need (usually) to search and then
manually open a cheatsheet.
2020-02-15 15:56:25 -05:00
Chris Lane
a6c25d4b9c feat: --search improvements
- Deprecates the `Match` struct

- Applies syntax highlighting to search results output in a manner
  consistent with the 'View' output

- Refactors search to move colorization functionality outside of its
  concern
2020-02-15 14:42:06 -05:00
Chris Lane
e24ac2b385 chore: deprecates line numbers in search
Removes line numbers from search result output as part of the
refactoring effort.
2020-02-15 10:11:25 -05:00
Chris Lane
e0c35a74d4 chore: removes colorization from search
Deprecates `mgutz/ansi` and removes colorization from search as a first
step toward improving the functionality.
2020-02-15 10:01:44 -05:00
Chris Lane
3e4c1818a9 feat: single-sheet searching
`--search` will now honor the `<cheatsheet>` argument, making it
possible to constrain a search to a single cheatsheet.
2020-02-15 06:38:57 -05:00
Chris Lane
7b4a268ebd fix: resolves
Fixes an issue whereby `cheat` would crash when `$EDITOR` (or
equivalent) contained arguments.
2020-02-02 15:56:18 -05:00
Chris Allen Lane
f7183aa17a
Merge pull request from chrisallenlane/issue-301
fix: issue 
2020-02-02 15:54:47 -05:00
Chris Lane
1ce6c29e6a fix: issue
Attempts to resolve issue , whereby `cheat` fails if `$EDITOR` (or
equivalent) contains flags.
2020-02-02 15:48:45 -05:00
Chris Allen Lane
219db679e1
Merge pull request from chrisallenlane/master
chore: bumps version to 3.5.0
2020-02-02 14:54:46 -05:00
Chris Lane
53177cb09d chore: bumps version to 3.5.0
Squashed commit of the following:

commit 8b74d50f1fabb28b0fe58eff651847d1e5b661dd
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Sun Feb 2 14:40:23 2020 -0500

    chore: updates README

    Edits the `README` to provid updated information regarding the shell
    autocompletion scripts and `fzf` integration.

commit 9868ba2d68d4c7ded6bca2eee5e8717605c8afab
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Sun Feb 2 14:39:04 2020 -0500

    chore: modifies envvar check

    Modifies the `CHEAT_USE_FZF` envvar check within the bash autocompletion
    script for clarity.

commit ac1012f743a23e3fae528206a81b4d71f06423c0
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Sun Feb 2 14:25:34 2020 -0500

    chore: renames autocompletion scripts

    Renames autocompletion scripts to conform with the conventions
    established in `scop/bash-completion`.

commit c8747bd91de99c8ddaa152ea38c9abf88c249029
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Sun Feb 2 14:23:03 2020 -0500

    feat: improved bash autocompletions

    - Dramatically improves quality of bash autocompletions

    - Provides optional integration with `fzf`

commit 825bd0139d7e6bc96084c3bed74429bd893453cd
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Sun Feb 2 09:19:46 2020 -0500

    chore: deletes `fzf.bash`

    Deletes `fzf.bash`, which was always intended to be a temporary
    placeholder anticipating future improvements.
2020-02-02 14:50:16 -05:00
Chris Allen Lane
ef7a41f9a9
Merge pull request from chrisallenlane/master
chore: creates `make coverage` target
2020-01-31 14:07:20 -05:00
Chris Lane
008316d030 chore: creates make coverage target
Creates a `make coverage` target that generates a unit-testing coverage
report.
2020-01-31 14:01:57 -05:00
Chris Lane
a59c019642 chore: removes bin directory
Removes the `bin` directory. It has been obsoleted by the `Makefile`,
and no downstream packages appeared to depend on it.
2020-01-31 13:30:21 -05:00
Chris Allen Lane
57225442be
Merge pull request from chrisallenlane/auto-config-bugfix
fix(config generation): issue 
2020-01-30 20:12:24 -05:00
Chris Lane
2c7ce48859 chore: multi-os builds on travis
Modifies `.travis.yml` to specify that builds be performed on both Linux
and MacOSX. Experimental.
2020-01-30 20:08:11 -05:00
Chris Lane
a3fe4f40bb chore: bumps version to 3.4.1 2020-01-30 20:06:06 -05:00
Chris Lane
506fb8be15 fix: XDG_CONFIG_HOME mishandling
Attempts to resolve an issue regarding automatic config file generation,
as referenced in . This issue is believed occur when
`XDG_CONFIG_HOME` is unset.
2020-01-30 19:59:35 -05:00
Chris Lane
408e944eea chore: refactors config.path (small)
Performs a minor refactoring on `config.Paths` to consistently use
`path.Join` when computing config directory paths. Previously, both
`path.Join` and `fmt.Sprintf` were being used, strictly due to an
oversight.
2020-01-30 19:45:02 -05:00
Chris Lane
8a313b92ca chore: implements unit-tests for config.Paths 2020-01-30 19:25:53 -05:00
Chris Lane
6912771c39 chore: refactors config.Paths
Refactors the reading of multiple envvars out of `config.Paths` in order
to facilitate cleaner unit-testing.
2020-01-30 18:48:36 -05:00
Chris Allen Lane
d4c6200702
Merge pull request from chrisallenlane/auto-config
feat(configs): config auto-generation
2020-01-29 14:22:12 -05:00
Chris Lane
9251849d23 chore: bumps version to 3.4.0 2020-01-29 14:17:06 -05:00
Chris Lane
313b5ebd27 feat: config auto-generation
`cheat` now attempts to auto-generate a config file if one cannot be
found on the filesystem.
2020-01-29 14:08:03 -05:00
Chris Lane
ca91b25b02 fix: logging on failed configs
Fixes an issue whereby the error message generated when a config file
could not be loaded (due to a symlink resolution failure) would fail to
print the config file path to `stderr`.
2020-01-29 14:05:27 -05:00
Chris Lane
bbf6af50b1 chore: modifies example config
- Generally reduces the complexity demonstrated in the example configs.
  The prior complexity appears to have confused some new users.

- Removes the `dotfiles` references in the example configs. This idiom
  likewise appears to have confused some new users.

- Adds some instruction regarding how to download and configure the
  "community" cheatsheets (`cheat/cheatsheets`).
2020-01-29 14:01:19 -05:00
Chris Lane
9f05442bce fix: Makefile
Resolves an error whereby `make build` would fail to call `go generate`
prior to calling `go build`.
2020-01-29 13:59:31 -05:00
Chris Lane
3fc4c2f89e chore: Makefile
Makes some adjustments to the behaviors of `make tags` and `make
distclean`.
2020-01-29 09:36:59 -05:00
Chris Lane
9e88ff2642 chore: Makefile adjustment
Previously, `build-release` would produce `.gz` files which had the
execute permission set. This modifies the `Makefile` to `chmod -x` the
`.gz` files after compression.
2020-01-29 09:11:06 -05:00
Chris Allen Lane
e3764b81e7
3.3.2 ()
* chore: trivial Makefile changes

Trivial `Makefile` changes regarding file pathing.

* chore: build flags

- Passes `-trimpath` flag to build tasks

- Creates `make ci` task and modifies `travis.yml` to use it

- Bumps version to `3.3.2`
2020-01-29 08:50:47 -05:00
Chris Allen Lane
3786ac96a5
3.3.1 ()
* makefile wip

* feat: adds Makefile

Adds a `Makefile` for managing build-related tasks.

* chore: updates dependencies

* chore: updates dependencies

* chore: updates bin scripts

- Removes `build_release.sh`
- Places deprecation notice in `build_devel.sh`, as its purpose has been
  superceded by the `Makefile`.

* chore: updates bin scripts

- Removes `build_release.sh`
- Places deprecation notice in `build_devel.sh`, as its purpose has been
  superceded by the `Makefile`.

* fix: Makefile

Makes several corrections and improvements to the `Makefile`:

- Previously, the `ifeq` rules were not behaving as intended, due to
  false assumptions regarding how `make` fundamentally behaves.
  Malfunctioning imperative-style programming has been replaced with
  declarative rules to repair this issue.

- Previously, all release executables were zipped after compilation. In
  order to spare non-Windows users from (possibly) needing to install a
  package to unzip the executables, all non-Windows binaries are now
  compressed with `gzip`. (Windows executables are still compressed with
  `zip`.)

- Removes a bit of needlessly verbosity in several rules and paths.

* chore: updates dependencies

* chore: bumps version to 3.3.1
2020-01-25 14:44:51 -05:00
aperum
4cb7a3b42c add FreeBSD to the supported systems in config.Path () 2020-01-25 14:33:15 -05:00
dependabot-preview[bot]
ff6a866abe chore(deps): bump gopkg.in/yaml.v2 from 2.2.7 to 2.2.8 ()
Bumps [gopkg.in/yaml.v2](https://github.com/go-yaml/yaml) from 2.2.7 to 2.2.8.
- [Release notes](https://github.com/go-yaml/yaml/releases)
- [Commits](https://github.com/go-yaml/yaml/compare/v2.2.7...v2.2.8)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-25 14:20:06 -05:00
dependabot-preview[bot]
2e7ccb2a68 chore(deps): bump github.com/mattn/go-isatty from 0.0.11 to 0.0.12 ()
Bumps [github.com/mattn/go-isatty](https://github.com/mattn/go-isatty) from 0.0.11 to 0.0.12.
- [Release notes](https://github.com/mattn/go-isatty/releases)
- [Commits](https://github.com/mattn/go-isatty/compare/v0.0.11...v0.0.12)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-25 14:19:57 -05:00
Chris Lane
126231db1f feat: makefile release compression
The `Makefile` `build-release` target now zips all executables after
compilation.
2020-01-20 13:54:53 -05:00
Chris Allen Lane
91f0d02de2
v3.3.0 ()
* feat: directory-scoped cheatpaths

`cheat` now searches for a `.cheat` directory in the current working
directory. If found, that directory is (temporarily) appended to the slice
of cheatpaths.

* makefile wip

* fix: appeases linter

Appeases linter (`go vet`) by adding quotation marks to YAML struct
tags.

* chore: modifies .gitignore

Adds `tag` to `.gitignore`

* feat: adds Makefile

Adds a `Makefile` for managing build-related tasks.

* chore: documents directory-local paths

Adds documentation regarding the new directory-local cheatpath
functionality.

* chore: updates dependencies

* chore: bumps version to 3.3.0

* chore: updates bin scripts

- Removes `build_release.sh`
- Places deprecation notice in `build_devel.sh`, as its purpose has been
  superceded by the `Makefile`.
2020-01-20 12:34:48 -05:00
Chris Allen Lane
815e714fb4
Merge pull request from cheat/dependabot/go_modules/github.com/alecthomas/chroma-0.7.1
chore(deps): bump github.com/alecthomas/chroma from 0.7.0 to 0.7.1
2020-01-19 17:05:16 -05:00
dependabot-preview[bot]
bd3986a051
chore(deps): bump github.com/alecthomas/chroma from 0.7.0 to 0.7.1
Bumps [github.com/alecthomas/chroma](https://github.com/alecthomas/chroma) from 0.7.0 to 0.7.1.
- [Release notes](https://github.com/alecthomas/chroma/releases)
- [Changelog](https://github.com/alecthomas/chroma/blob/master/.goreleaser.yml)
- [Commits](https://github.com/alecthomas/chroma/compare/v0.7.0...v0.7.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-09 07:03:22 +00:00
Chris Allen Lane
f47b75edc0
Merge pull request from chrisallenlane/master
chore: dependencies and build script
2019-12-28 10:08:32 -05:00
Chris Lane
180ee20f77 chore: bumps version to 3.2.2 2019-12-28 09:58:48 -05:00
Chris Lane
9b86c583f8 chore: updates chroma dependency 2019-12-28 09:56:19 -05:00
Chris Lane
e1f7828869 Merge branch 'master' of github.com:cheat/cheat into issue-520 2019-12-28 09:54:39 -05:00
Chris Lane
7f3ae2ab30 feat: ARM support
Modifies `bin/build_release.sh` to compile releases for ARM versions 5,
6, and 7.
2019-12-28 09:53:55 -05:00
Chris Allen Lane
bbd03a1bb8
Merge pull request from cheat/dependabot/go_modules/github.com/alecthomas/chroma-0.7.0
chore(deps): bump github.com/alecthomas/chroma from 0.6.9 to 0.7.0
2019-12-28 09:53:22 -05:00
Chris Lane
326c54147b chore: updates dependencies 2019-12-28 09:07:37 -05:00
dependabot-preview[bot]
efcedaedec
chore(deps): bump github.com/alecthomas/chroma from 0.6.9 to 0.7.0
Bumps [github.com/alecthomas/chroma](https://github.com/alecthomas/chroma) from 0.6.9 to 0.7.0.
- [Release notes](https://github.com/alecthomas/chroma/releases)
- [Changelog](https://github.com/alecthomas/chroma/blob/master/.goreleaser.yml)
- [Commits](https://github.com/alecthomas/chroma/compare/v0.6.9...v0.7.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-28 14:06:13 +00:00
Chris Allen Lane
301cbefb0c
Merge pull request from cheat/dependabot/go_modules/github.com/mattn/go-isatty-0.0.11
chore(deps): bump github.com/mattn/go-isatty from 0.0.10 to 0.0.11
2019-12-28 09:04:43 -05:00
dependabot-preview[bot]
9a481f7e75
chore(deps): bump github.com/mattn/go-isatty from 0.0.10 to 0.0.11
Bumps [github.com/mattn/go-isatty](https://github.com/mattn/go-isatty) from 0.0.10 to 0.0.11.
- [Release notes](https://github.com/mattn/go-isatty/releases)
- [Commits](https://github.com/mattn/go-isatty/compare/v0.0.10...v0.0.11)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-11 07:07:50 +00:00
Chris Allen Lane
e2920bd922
Merge pull request from chrisallenlane/master
fix: colorization errors
2019-11-24 12:17:19 -05:00
Chris Lane
973a1f59ea chore: version bump
Bumps version to `3.2.1`.
2019-11-24 12:03:26 -05:00
Chris Lane
3afea0972c fix: colorization errors
- Corrects an error with `--search`. Previously, `--search` was not
  aware of whether it was outputted to a TTY, and would apply colorization
  at all times. This resulted in unwanted behavior when, for example,
  piping search results into a paginator.

- Corrects an error with `--color`. Previously, `--color` would be
  ignored if output was being written to a non-TTY. This made it
  impossible, for example, to `cheat tar --color | less -R`, as
  colorization would always be stripped. The behavior of `--color` has
  been modified such that it now behaves similarly to `--color=always` in
  other applications.
2019-11-23 13:47:08 -05:00
Chris Allen Lane
f86633ca1c
Merge pull request from chrisallenlane/master
Resolves 
2019-11-20 19:02:50 -05:00
Chris Lane
a01a3491a4 chore: version bump
Bumps version to 3.2.0.
2019-11-20 18:56:50 -05:00
Chris Lane
daa43d3867 feat: implements filter on -l
Implements filtering by pattern with `-l`. Resolves .
2019-11-20 18:55:43 -05:00
Chris Lane
e94a1e22df chore: updates vendored dependencies 2019-11-20 18:55:24 -05:00
Chris Allen Lane
5046975a0f
Merge pull request from cheat/dependabot/go_modules/gopkg.in/yaml.v2-2.2.7
chore(deps): bump gopkg.in/yaml.v2 from 2.2.5 to 2.2.7
2019-11-20 18:53:54 -05:00
dependabot-preview[bot]
198156a299
chore(deps): bump gopkg.in/yaml.v2 from 2.2.5 to 2.2.7
Bumps [gopkg.in/yaml.v2](https://github.com/go-yaml/yaml) from 2.2.5 to 2.2.7.
- [Release notes](https://github.com/go-yaml/yaml/releases)
- [Commits](https://github.com/go-yaml/yaml/compare/v2.2.5...v2.2.7)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-20 07:07:43 +00:00
Chris Lane
a7067279df v3.1.1
Bumps version to `3.1.1`.
2019-11-19 19:59:45 -05:00
Stefan Cosma
a8e6fdb18a Properly trim path separators on Windows 2019-11-20 01:10:19 +01:00
Chris Allen Lane
bbfa4efdb7
Merge pull request from exploide/fish-autocompletion
fish autocompletion: updated to cheat 3.1.0
2019-11-17 18:12:41 -05:00
exploide
741ad91389 fish autocompletion: updated to cheat 3.1.0 2019-11-17 19:33:33 +01:00
Chris Allen Lane
573d43a7e6
Merge pull request from chrisallenlane/3.1.0
3.1.0
2019-11-16 09:27:18 -05:00
Chris Lane
879e8f2be4 chore: trivial copy change in docopt.txt 2019-11-16 09:23:45 -05:00
Chris Lane
eab3c14f1f fix: broken logline in --search
Resolves a malformed logging statement in `cmd_search` which would never
actually write to stderr.
2019-11-16 09:18:45 -05:00
Chris Lane
9a6130b6b7 feat: --rm and --tags
- Implements the `--rm` command ()
- Implements the `--tags` command ()
- Bumps version to `3.1.0`
2019-11-16 09:18:32 -05:00
Chris Lane
aeaf01e1de feat: implements --tags
Implements `--tags`, which lists all tags in use.
2019-11-14 21:56:11 -05:00
Chris Lane
09c29a322f chore: bumps version to 3.0.7 2019-11-12 19:16:21 -05:00
Chris Lane
0525b2331b chore: updates vendored dependencies
Updates `alecthomas/chroma` and `gopkg.in/yaml.v2` to newer versions.
2019-11-12 19:03:59 -05:00
Chris Lane
27a4991a3a feat: updates build scripts
Build scripts now invoke `go mod vendor` and `go mod tidy` early in the
build process, to ensure that the `vendor` directory stays consistent
with the `go.mod` et. al.
2019-11-12 19:02:42 -05:00
Chris Lane
4dda412dcb Merge branch 'dependabot/go_modules/github.com/alecthomas/chroma-0.6.9' 2019-11-12 18:55:16 -05:00
Chris Lane
bfb60764ad Merge branch 'master' into dependabot/go_modules/github.com/alecthomas/chroma-0.6.9 2019-11-12 18:54:02 -05:00
Chris Lane
3a97c680bb Merge branch 'dependabot/go_modules/gopkg.in/yaml.v2-2.2.5' 2019-11-12 18:53:40 -05:00
dependabot-preview[bot]
edc0fe41ef
Bump github.com/alecthomas/chroma from 0.6.8 to 0.6.9
Bumps [github.com/alecthomas/chroma](https://github.com/alecthomas/chroma) from 0.6.8 to 0.6.9.
- [Release notes](https://github.com/alecthomas/chroma/releases)
- [Changelog](https://github.com/alecthomas/chroma/blob/master/.goreleaser.yml)
- [Commits](https://github.com/alecthomas/chroma/compare/v0.6.8...v0.6.9)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-12 23:42:53 +00:00
dependabot-preview[bot]
9e49bf8e9c
Bump gopkg.in/yaml.v2 from 2.2.4 to 2.2.5
Bumps [gopkg.in/yaml.v2](https://github.com/go-yaml/yaml) from 2.2.4 to 2.2.5.
- [Release notes](https://github.com/go-yaml/yaml/releases)
- [Commits](https://github.com/go-yaml/yaml/compare/v2.2.4...v2.2.5)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-12 23:42:30 +00:00
Chris Lane
50dc3c8b29 fix: resolves
Resolves an issue whereby background colors were written to the terminal
output when colorization was applied.
2019-11-07 20:24:08 -05:00
Chris Lane
e08a4f3cec chore: bumps version to 3.0.5 2019-11-07 20:00:57 -05:00
Chris Lane
d6ebe0799d fix: repairs broken config unit-tests
Repairs the `config` unit-tests which were broken with `3.0.4`. It does
so by providing a simple switch that allows us to disable the resolution
of filesystem symlinks when running tests.
2019-11-07 19:59:18 -05:00
Chris Lane
51aaaf3423 chore: removes the tj/front dependency
Removes the `tj/front` dependency due to licensing concerns. See .
2019-11-07 06:46:34 -05:00
Chris Lane
197ff58796 fix: comments out more broken tests
Comments out another test broken by `3.0.4`.
2019-11-05 20:02:16 -05:00
Chris Lane
b8f512aae8 fix: comments out broken test
Comments out a test that was broken with changes introduced in `3.0.4`.
2019-11-05 19:58:08 -05:00
Chris Lane
e7a1a296e3 chore: version bump
Version bump to `3.0.4`.
2019-11-05 19:19:17 -05:00
Chris Lane
f7c093bec0 fix: resolves
Resolves , whereby `cheat` failed to resolve symlinks. The root
cause was that `path/filepath#Walk` simply does not resolve symlinks:

  https://golang.org/pkg/path/filepath/#Walk
2019-11-05 19:08:40 -05:00
Chris Lane
c47b7f81aa fix: file permissions
Set executable permission on `scripts/cheat-autocompletion.fish`.
2019-11-05 18:49:05 -05:00
Chris Lane
52081b97ac Merge branch 'fish-completions' of github.com:exploide/cheat into exploide-fish-completions 2019-11-05 18:46:58 -05:00
Chris Lane
1dda796e7c fix: resolves
Fixes an issue whereby hidden files (like `.DS_Store`) may be wrongly
loaded as cheatsheets.
2019-11-05 18:44:47 -05:00
exploide
67469b0afa added cheat 3.x autocompletion file for fish shell, see 2019-11-05 17:29:32 +01:00
exploide
4f8431a600 fixed some cli option typos 2019-11-05 15:53:21 +01:00
Chris Lane
5301442f7c chore: issue template labels 2019-11-04 18:43:52 -05:00
Chris Allen Lane
cd45efcdec Update issue templates 2019-11-04 18:42:21 -05:00
Chris Lane
c31786fc5b chore: updated the bug report template 2019-11-04 18:40:46 -05:00
Chris Allen Lane
934c36ad77 Update issue templates 2019-11-04 18:37:26 -05:00
Chris Allen Lane
2c0099c28a
Merge pull request from zhujian0805/master
adding the cheat autocomplete script back :)
2019-11-04 18:12:12 -05:00
Chris Lane
33ac3d34d1 fix: removed colorization on non-tty
Fixes a bug whereby `cheat` would apply ANSI colorization even when
outputting into a non-TTY.
2019-10-29 19:47:56 -04:00
Chris Lane
10af84dc10 chore: bump version
Bumps the version to `3.0.2`.
2019-10-28 19:44:08 -04:00
Chris Lane
8d532bcdee Merge branch 'add-travis-ci' of github.com:chenrui333/cheat into chenrui333-add-travis-ci 2019-10-28 19:41:23 -04:00
Chris Lane
a13ad99241 chore: modified build scripts
Modified build scripts to always use local vendoring, now that the
project contains a `vendor` directory.
2019-10-28 19:39:22 -04:00
Rui Chen
1a8345f326 Add travis build badge 2019-10-27 18:44:44 -04:00
Rui Chen
472e1f84f5 Add travis-ci 2019-10-27 18:31:16 -04:00
Rui Chen
659e0a8eff Add vendor files for go build 2019-10-27 12:04:31 -04:00
Chris Lane
d19f0e1c5d chore: deprecates bin/deps.sh
- Deprecates `bin/deps.sh`. It was rendered obsolete with 217566, and
  the introduction of a `go.mod` file.
- Fixes two minor typos in the buld scripts.
- Bumps the version to `3.0.1`.
2019-10-27 10:26:24 -04:00
Chris Lane
0f9861f825 Merge branch 'gomod' of github.com:dawidd6/cheat into dawidd6-gomod 2019-10-27 09:35:13 -04:00
Chris Lane
36960fc164 chore: adds license and contributing file 2019-10-26 16:13:46 -04:00
James Zhu
749173f1f6 remove the title as cheat -l lists the title as well. 2019-10-22 11:58:51 +08:00
Dawid Dziurla
217566efc5
Use Go modules 2019-10-21 12:51:56 +02:00
James Zhu
33e33dc7b7 adding the autocompletion back 2019-10-21 18:07:26 +08:00
James Zhu
201cd1d629 integrate with bash complete for autocompletion 2019-10-21 15:18:47 +08:00
Chris Lane
e5114a3e76 Re-wrote from scratch in Golang
- Re-implemented the project in Golang, and deprecated Python entirely
- Implemented several new, long-requested features
- Refactored cheatsheets into a separate repository
2019-10-20 10:02:28 -04:00
Chris Allen Lane
307c4e6ad6
Merge pull request from asamarin/master
Add: sqlite3 - describe table schema
2019-10-16 06:13:40 -04:00
Chris Allen Lane
1333703a49
Merge pull request from thezeroalpha/master
ssh-keygen: add commands to print the fingerprint
2019-10-16 06:09:44 -04:00
Chris Allen Lane
184c200936
Merge pull request from extend1994/Fix-netstat
Add missing spaces for netstat command comment
2019-10-16 06:06:13 -04:00
Ann
f1837b4c59
Add missing spaces for netstat command comment 2019-10-15 13:58:57 +08:00
Alex Samarin
77d0f6d9a0 Add: sqlite3 - describe table schema 2019-10-14 09:54:38 +01:00
Alex Balgavy
5b2518b3fe ssh-keygen: add commands to print the fingerprint 2019-09-08 23:32:13 -04:00
Chris Lane
60bf61c82f Merge branch 'TomasKorbar-installation-issues' 2019-09-03 12:48:51 -04:00
Chris Allen Lane
b1dabec129
Merge pull request from FlorianKempenich/master
Add cheatsheet for `z`
2019-08-28 08:39:47 -04:00
Florian Kempenich
d10290541d Add cheatsheet for z 2019-08-03 13:29:18 +01:00
Tomas Korbar
12e8059025 Edit appdirs site_config_dir function
This change causes site_config_dir function to return
/etc/cheat on linux systems. This is right because most
linux distributions follow FHS where /etc is a directory
which contains system-wide configuration files.
2019-07-24 14:23:46 +02:00
Chris Allen Lane
ea07b6ad0e
Merge pull request from rengoo/patch-1
Update zip
2019-07-01 18:54:53 -04:00
Chris Allen Lane
c50b236b80
Merge pull request from Asta1986/master
improved command to export query result to csv file
2019-07-01 18:53:44 -04:00
Chris Allen Lane
42a39449b3
Merge pull request from rafaelbernard/vim-multiple-windows
Add: vim - multiple windows
2019-07-01 18:51:56 -04:00
Chris Allen Lane
087a076f74
Merge pull request from santosomar/patch-1
Addition additional nmap options
2019-07-01 18:50:31 -04:00
Chris Allen Lane
a15ea7fc3e
Merge pull request from shanahanjrs/issue-334-emacs-fix
Emacs sheet now uses the proper prefix
2019-07-01 18:47:24 -04:00
Chris Allen Lane
f33e6cd602
Merge pull request from dogsleg/patch-1
Fix typo, action (-I -> -l)
2019-07-01 18:38:57 -04:00
Chris Allen Lane
95f648cc2d
Merge pull request from jellymann/patch-1
fix: typo in vagrant sheet
2019-07-01 18:33:16 -04:00
Chris Allen Lane
0db660347b
Merge pull request from sullivant/patch-1
Updated tmux cheat to include swapping windows
2019-07-01 18:32:47 -04:00
Thomas
432461a075
Updated tmux cheat to include swapping windows
Because I always forget.
2019-06-13 07:36:11 -05:00
Omar Santos
93df3b3f20
Update nmap
Added Nmap Scripting Engine Categories
2019-06-02 18:56:31 -04:00
Omar Santos
c548ded02d
Addition additional nmap options
Added "Port Status Information" and Additional Scan Types
2019-06-02 18:53:03 -04:00
Rafael Araujo
4c12d66546 Add: vim - multiple windows 2019-05-04 20:43:26 -03:00
Daniel Smith
6ce53370e7
fix: typo in vagrant sheet 2019-04-16 13:50:58 +02:00
rengoo
bde74c701f
Update zip
added command for creating a zip archive from a folder/directory
2019-04-13 20:59:08 +02:00
Tomas Korbar
fdc414ede3 Fix import of appdirs in Configuration class
Import of appdirs without reference to cheat module caused
ModuleNotFoundError
2019-03-21 16:47:51 +01:00
Lev Lamberov
5c23f374e4
Fix action (-I -> -l)
dpkg -I (capital i) is for showing information about a package.
dpkg -l (lowercase l) is for listing packages matching given pattern.

So, here is a fix for the typo.
2019-03-09 10:17:46 +05:00
Chris Lane
c1fceb5f0d Merge branch 'installation-issues' of github.com:cheat/cheat into installation-issues 2019-02-13 12:55:30 -05:00
Chris Lane
d0faf1a3e3 Included appdirs in project
The prior attempt to resolve  and  relied on `appdirs` to
determine the appropriate directories into which to install files.
Previously, `setup.py` dynamically attempted to install `appdirs` via
`pip` during installation if necessary.

This attempt to failed on multiple platforms, however, due to
backwards-incompatible `pip` interfaces.

As a workaround, I have now directly included `appdirs` (a small module)
within `cheat` itself. This approach is explicitly supported per the
`appdirs` documentation:

https://pypi.org/project/appdirs/
2019-02-13 12:53:19 -05:00
Chris Lane
fdddedb8bd Installation issues
Resolves the following:

-  (use of `sudo` when installing)
-  (failure to install on Windows)
-  (failure to install on MacOS)

Application now relies on `appdirs` module to identify the appropriate
locations for storing configuration and data, both during installation
and runtime.
2019-02-13 12:51:18 -05:00
Chris Lane
5487314676 Version bump: 2.5.1 2019-02-13 12:42:58 -05:00
Chris Allen Lane
ec360ccddd
Merge pull request from roachsinai/master
Expand ~ for 'CHEAT_USER_DIR', 'CHEAT_DEFAULT_DIR' and 'DEFAULT_CHEAT…
2019-02-13 12:40:25 -05:00
Chris Allen Lane
bb7dfd1028
Merge pull request from avsej/patch-1
Fix typo in gcc sheet
2019-02-13 12:31:31 -05:00
Sergey Avseyev
b348724082
Update gcc 2019-02-13 13:52:33 +00:00
raochsinai
5053f07fd8 Expand ~ for 'CHEAT_USER_DIR', 'CHEAT_DEFAULT_DIR' and 'DEFAULT_CHEAT_DIR'. 2019-02-12 15:16:59 +08:00
Chris Lane
f692c8e1d8 Addressing cross-platform installation issues
Attempted to address various cross-platform installation issues:

- Removed all hard-coded references to file-paths, and replaced them
  with paths provided by `appdirs`.

- Removed (erroneously inserted) default file paths which would never be
  checked due to application logic.

- Modified `setup.py` to no longer install a configuration file. The
  mechanics are still in place to **read** a configuration file, but
  after examination, I've concluded that the installation of that file
  is best left to package maintainers rather than `cheat` itself.
2019-02-09 13:27:58 -05:00
Chris Lane
89bb9aaf13 Included appdirs in project
The prior attempt to resolve  and  relied on `appdirs` to
determine the appropriate directories into which to install files.
Previously, `setup.py` dynamically attempted to install `appdirs` via
`pip` during installation if necessary.

This attempt to failed on multiple platforms, however, due to
backwards-incompatible `pip` interfaces.

As a workaround, I have now directly included `appdirs` (a small module)
within `cheat` itself. This approach is explicitly supported per the
`appdirs` documentation:

https://pypi.org/project/appdirs/
2019-02-08 11:21:09 -05:00
John Shanahan
574deeabc0 Emacs sheet now uses the proper prefix 2019-02-07 14:16:08 -05:00
Chris Lane
482161f8e9 Installation issues
Resolves the following:

-  (use of `sudo` when installing)
-  (failure to install on Windows)
-  (failure to install on MacOS)

Application now relies on `appdirs` module to identify the appropriate
locations for storing configuration and data, both during installation
and runtime.
2019-02-07 13:34:20 -05:00
Chris Allen Lane
4dd55105d2
Merge pull request from aroonav/master
Enable starting the cheat python script on windows.
2019-02-06 10:25:29 -05:00
Chris Allen Lane
6148d64599
Merge pull request from movd/rename
Update rename
2019-02-05 08:59:06 -05:00
Moritz
cde8bcaa1d
Update rename
Add cheat for mass rename with search and replace
2019-02-05 10:57:43 +01:00
Aroonav Mishra
fcb82778e4 * Corrected the logic to execute the cheat script.
* Check VISUAL, CHEAT_EDITOR, EDITOR environment variables before falling
back to wordpad as the default editor.
2019-02-05 12:18:26 +05:30
Aroonav Mishra
da92421948 Merge remote-tracking branch 'upstream/master' 2019-02-05 10:14:39 +05:30
Chris Allen Lane
d6c7863573
Merge pull request from dufferzafar/patch-2
ssh: Improve SOCKS command
2019-02-04 14:54:52 -05:00
Shadab Zafar
5812bca6b7
ssh: Improve SOCKS command
This doesn't give an SSH shell, but just forwards the ports - which is what one usually requires when setting up a SOCKS proxy.

The -q is to suppress messages etc.
2019-02-04 23:45:16 +05:30
Chris Lane
074dba6e99 v2.5.0
`minor` version bump to `2.5.0`.
2019-02-04 12:04:52 -05:00
Chris Allen Lane
9d1dd15387
Merge pull request from cheat/issue-349
Issue 
2019-02-04 11:57:35 -05:00
Chris Lane
caf355f142 Issue
Implements support for terminals with light backgrounds via a new
`CHEAT_COLORSCHEME` envvar.
2019-02-04 11:56:00 -05:00
Chris Allen Lane
2728ce4757
Merge pull request from cheat/vagrant
Updated Vagrantfile
2019-02-04 11:54:06 -05:00
Chris Lane
6ae76799f7 Updated Vagrantfile
Modified `Vagrantfile` to build an Ubuntu environment rather than
Alpine, after the latter exhibited weird behavior.
2019-02-04 11:50:25 -05:00
Chris Allen Lane
0b523a769f
Merge pull request from cheat/vagrant
Added Vagrantfile
2019-02-04 10:41:26 -05:00
Chris Lane
f29cf03b68 Added Vagrantfile
Added a `Vagrantfile` which builds an alpine-based environment that can
be used for development and testing.
2019-02-04 10:40:10 -05:00
Chris Allen Lane
4347114e19
Merge pull request from JensKorte/patch-1
link changed, added details
2019-02-04 10:05:36 -05:00
Chris Lane
edc67e7819 Updated links to README
Re-pathed links from `chrisallenlane/cheat` to `cheat/cheat` as
appropriate, following the move.
2019-02-04 10:03:19 -05:00
Chris Allen Lane
aa33a36491
Merge pull request from cheat/refactor
Refactor
2019-02-04 09:58:24 -05:00
JensKorte
8aac10dd8b
link changed, added details
The table isn't available any more in the recent wiki page. The new link uses the old version of wikipedia. In my browser I have to "unhide" the box.
2019-02-03 20:56:57 +01:00
Chris Lane
9931b78c5f Lint
- Added instruction to lint `setup.py` to `ci/lint.sh`
- Updated `setup.py` per linter suggestions
2019-02-01 15:24:04 -05:00
Chris Lane
a37577ee85 Trivial: docstrings
Updated some docstring comments.
2019-02-01 15:18:23 -05:00
Chris Lane
3ad923eff0 Refactored (11)
Renamed `CHEAT_DEFAULT_DIR` to `CHEAT_USER_DIR` because the latter more
accurately describes the purpose of the variable.
2019-02-01 15:10:03 -05:00
Chris Lane
ba47dc2cbc Refactored (10)
- Added `ci/lint.sh`, which uses `flake8` to lint the relevant files
- Made changes to appease the linter.
- Bugfix in `cheat/configuration` (missing dependency)
2019-02-01 14:44:48 -05:00
Chris Lane
df21731c02 Trivial Python style corrections 2019-02-01 11:43:38 -05:00
Chris Lane
a657699a24 Refactored (9)
Moved some functionality into the `Util` class.
2019-02-01 11:43:11 -05:00
Chris Lane
5793c1845a Refactored (8)
Refactored `Sheet` class:

- Removed unnecessary indirection and extraneous methods
- Renamed some methods to conform to Pythonic conventions
- Renamed the `create_or_edit` method to `edit` to be consistent with
  subcommand name (`--edit`)
2019-02-01 11:23:38 -05:00
Chris Lane
e2b5728283 Refactored (7)
Refactored for general code-clarity, with particular focus on removing
needless abstraction within `Sheet` and `Sheets` classes.
2019-01-31 20:03:56 -05:00
Chris Lane
d61e4e7c34 Refactored (6)
Standardized (mostly) how the various classes are initialized.
2019-01-31 18:08:19 -05:00
Chris Lane
145a81dcd6 Var renames
Replaced more references to deprecated envvar names to their newer
counterparts.
2019-01-31 17:55:26 -05:00
Chris Lane
7c4fc54681 Refactored (5)
- Extracted `Colorize` class out of `Util` class. (The latter now only
  contains static methods.)
- Renamed methods in `Colorize` class for improved clarity.
- Refactored as necessary to accommodate the changes above.
2019-01-31 17:43:21 -05:00
Chris Lane
878d7e7e1b Refactored (4)
Improved handling of edge-cases in `configuration.py`.
2019-01-31 17:40:53 -05:00
Chris Lane
928637c9db Refactored (3)
Removed unnecessary `import` calls.
2019-01-31 17:14:21 -05:00
Chris Lane
ab87bb11c4 Refactored (2)
Created an `Editor` class out methods in the `Util` class to enhance
code clarity.
2019-01-31 17:03:21 -05:00
Chris Lane
8f757d7735 Refactored (1)
Performed a general refactoring, focusing on the following:

- Removing layers of abstraction in config handling
- Stubbing out proper config validator
- Updating envvar names located throughout the project
2019-01-31 16:45:28 -05:00
Chris Lane
c922ef4c8d Version bump: 2.4.2
Contains `termcolor` dependency fix.
2019-01-29 11:45:43 -05:00
Chris Allen Lane
574a7ec3c9
Merge pull request from chrisallenlane/termcolor
Added termcolor dependency to setup.py
2019-01-29 11:44:22 -05:00
Chris Lane
5ae49228b7 Added termcolor dependency to setup.py
Added a missing `termcolor` dependency to `install_requires` in
`setup.py`. `termcolors` was introduced as an optional dependency when
the `CHEAT_HIGHLIGHT` envvar was implemented.
2019-01-29 11:42:14 -05:00
Chris Lane
09acdf1a69 README edits
Updated the names of the (preferred) cheat-related environment
variables, which have been changed in recent versions.
2019-01-29 11:31:03 -05:00
Chris Lane
9ea60d12ff Version-bump to 2.4.1
- Includes various bugfixes regarding UTF-8 encoding
- Adds new cheatsheets
2019-01-29 10:58:57 -05:00
Chris Allen Lane
f7d747e101
Merge pull request from butzel-net/master
suggestion for socat
2019-01-29 10:22:44 -05:00
Chris Lane
3b207b4d51 Merge branch 'dev' 2019-01-29 10:19:48 -05:00
Chris Allen Lane
5e1d3abce8
Merge pull request from chrisallenlane/issue-414-build-opts
Issue  - snap package compatibility
2019-01-29 10:18:55 -05:00
Chris Allen Lane
ad25e16dc6
Merge pull request from chrisallenlane/issue-372
Addressing issue 
2019-01-29 10:15:55 -05:00
Chris Allen Lane
92c07c0137
Merge pull request from chrisallenlane/issue-414-build-opts
Issue  - snap package compatibility
2019-01-27 14:50:37 -05:00
Chris Allen Lane
7e35263e90
Merge pull request from chrisallenlane/issue-372
Addressing issue 
2019-01-27 14:45:41 -05:00
Chris Lane
1b6b5b79b7 Version bump: 2.4.0
Preparing a new `minor` release.
2019-01-27 14:36:57 -05:00
butzel
b377984b59
suggestion for socat
butzel's suggestions for a socat cheatsheet
2019-01-25 12:46:01 +01:00
Chris Lane
e319332138 Issue - snap package compatibility
PR  changed the locaton into which system-wide cheatsheets are
installed to `/usr/share/cheat`, in order to comply with FHS. However,
this is causing conflicts with the `snap` packaging process.

This commit removes hard-coded references to `/usr/share/cheat` (outside
of `config/cheat`), and instead reads the cheat path via the
`CHEAT_PATH` config value (which may be set either in `cheat/config`, or
exported as an environment variable).

Lastly, this commit makes `setup.py` "aware of" the `CHEAT_PATH` env
var, allowing us to specify to where sytem-wide cheatsheets should be
installed during the `snap` build.
2019-01-21 12:58:03 -05:00
Chris Lane
13c0ea7525 Addressing issue
Previous pull-requests  and  attempted to resolve . They
were, however, never merged in.

Given that  was just merged (which rewrites a significant amount of
prior code), I here took what we learned from  and  and
re-implemented it. This approach will be less error-prone than
attempting to rebase either of the former on the changes introduced in
 .
2019-01-18 14:50:00 -05:00
Chris Lane
87448c49fa Merge branch 'TomasKorbar-changes' 2019-01-18 14:28:06 -05:00
Tomas Korbar
80b8cfc06b Add new env variables but hold compatibility with old ones
Legacy environmental variables like CHEATCOLORS are now higher in
configuration hiearchy than new environmental variables in
configuration files
2019-01-18 18:03:15 +01:00
Tomas Korbar
8a8f30679d Fix problems with CHEATCOLORS behaviour 2019-01-17 17:10:01 +01:00
Tomas Korbar
4d19505b79 Conform code to pep8 2019-01-15 19:38:24 +01:00
Tomas Korbar
a2e028fd19 Move validation of CHEAT_HIGHLIGHT value to Configuration class
Method _check_configuration should be used for validating all bad
values from now on
2019-01-15 19:21:33 +01:00
Tomas Korbar
5eec6bf040 Improve handling of settings
Constructors of classes which need direct access to configuration
now take Config class instance as parameter which will give them
better maintainability in the future

CHEAT_HIGHLIGHT has been added to Configuration class
2019-01-15 19:13:30 +01:00
Tomas Korbar
3a4c2a887d Add ConfigurationTestCase
- tests prove descending hiearchy of config system
- env vars, local config file, global config file
2019-01-15 17:09:39 +01:00
Tomas Korbar
879a58b721 Read env vars for global and local config path
- allows to change these paths for testing purposes and also
gives user option to change his config paths
2019-01-15 17:09:39 +01:00
Tomas Korbar
7814de96d2 Add classes for better readability 2019-01-15 17:09:39 +01:00
Tomas Korbar
a651426075 Add reading settings from configuration file 2019-01-15 17:09:35 +01:00
Tomas Korbar
c4c935a6a5 Change default location of cheatsheets 2019-01-15 16:48:07 +01:00
Chris Allen Lane
df86142b8e
Merge pull request from chrisallenlane/snap-cheatsheet
Created a `snap` cheatsheet
2019-01-11 17:19:08 -05:00
Chris Lane
60b05c8781 Created a snap cheatsheet 2019-01-11 17:18:02 -05:00
Chris Lane
22b64d2d08 Merge branch 'master' of https://github.com/liuyang1/cheat into liuyang1-master
Resolving merge-conflicts.
2019-01-11 17:00:39 -05:00
Chris Lane
1224908445 README edits
Updated the README to mention the new `CHEAT_HIGHLIGHT` environment
variable.
2019-01-11 16:36:17 -05:00
Chris Lane
28a2902e20 Implemented validation on CHEAT_HIGHLIGHT
Implemnted an assertion that `CHEAT_HIGHLIGHT` (if set) contains a value
that is acceptible to `termcolors`. This happens only once, upon the
invokation of `__main__`. If the assertion fails, `cheat` terminates
with an exit code of `1`.
2019-01-11 16:26:57 -05:00
Chris Lane
730c488854 Introduced CHEAT_HIGHLIGHT
Introduced CHEAT_HIGHLIGHT environment variable to de-couple search-term
highlighting from syntax highlighting.
2019-01-11 16:13:38 -05:00
Chris Lane
ba9051e3cd highlight bug-fix
Fixed a bug in `cheat/utils.py` that would cause `highlight` to return
the wrong value when `CHEATCOLORS` was not set.
2019-01-11 15:58:21 -05:00
Chris Lane
7c7278ac8b Util logic simplification
- Simplified the logic regarding checking the state of `CHEATCOLORS` in
  `cheat/utils.py`

- Improved the commenting within the same
2019-01-11 15:54:20 -05:00
Chris Lane
e1fdca231e Merged with changes
PR  implemented highlighting on search terms within search results.
This PR:

- Merges the above
- Makes a few modifications upon the implementation

Specifically, the new implementation no longer relies on hard-coded
escape-sequences. Instead, a new `highlight` function has been created,
which in turn attempts to defer to the `termcolors` library to colorize
the necessary text.
2019-01-11 15:46:54 -05:00
Chris Lane
6b796adaf7 README edit
Edited the addition regarding Pygments.
2019-01-11 15:13:41 -05:00
Joaquin Garmendia Cabrera
95843e4674 Updating dependencies to highlighting 2019-01-11 15:10:39 -05:00
Chris Allen Lane
2b58300d84
Merge pull request from gorshkov/master
Fix url in curl cheatsheet
2019-01-11 14:20:18 -05:00
Chris Allen Lane
bf1be86fb9
Merge pull request from FlorianKempenich/master
Add cheatsheet for `scd`
2019-01-11 14:19:22 -05:00
Chris Allen Lane
35c4a8d639
Merge pull request from sundar-raman/master
Disable colorized output when CHEATCOLORS is not "true", or not set
2019-01-11 14:13:21 -05:00
Chris Lane
6910adae90 Merge branch 'master' of github.com:chrisallenlane/cheat 2019-01-11 14:05:55 -05:00
Chris Lane
b47b4bc1d1 Modified .gitignore
Added `.env` to the list of ignored files.
2019-01-11 14:05:38 -05:00
Chris Allen Lane
ea7e71b002
Merge pull request from idarlund/patch-2
Update ssh
2019-01-11 14:04:11 -05:00
Chris Allen Lane
d576eef13b
Merge pull request from idarlund/patch-3
Update scp
2019-01-11 14:03:31 -05:00
Chris Allen Lane
bec516b30a
Merge pull request from hutchison/master
Fixed a typo.
2019-01-11 14:02:39 -05:00
Martin Darmüntzel
f0b3f8037b
Fixed a typo. 2019-01-09 15:47:49 +01:00
Idar Lund
3938032595
Update scp
scp over socks
2019-01-08 08:24:16 +01:00
Idar Lund
f35cfa084e
Update ssh
added ssh over socks tunnel
2019-01-08 08:19:09 +01:00
Evgeny
cdb22f310d
Fix url in curl cheatsheet 2018-12-19 21:11:54 +07:00
Sundar Raman
6d1eff16a1 Disable colorized output when CHEATCOLORS is not "true", or not set 2018-11-11 13:04:51 +08:00
Florian Kempenich
9241de04d6
Update formatting to adhere to the guideline. 2018-10-25 11:37:39 +01:00
Florian Kempenich
8ac1851a69
Add cheatsheet for scd
`scd` is a fantastic `oh-my-zsh` plugin to quickly jump between directories.
See here: https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/scd
2018-10-25 11:34:25 +01:00
liuyang1
c0fe871b33 fix except case
- when redirect stdout to pipe but not tty, it throw exception.
- when have no content, it throw exception.
- remove reductant newline at end of file
2018-06-13 18:58:37 +08:00
Astaroth
9c53e2ba10 improved command to export query result to csv file 2017-12-05 15:44:49 -03:00
Aroonav Mishra
d048ea5a10 Enable starting the cheat python script on windows.
For this add a small batch script in the same directory as the
cheat script.
2017-11-12 18:48:04 +05:30
sunyakun
761bf2eb2f hightlight the search keywords 2017-10-12 09:25:20 +08:00
1797 changed files with 426251 additions and 6617 deletions

23
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file

@ -0,0 +1,23 @@
---
name: Bug report
about: Submit a bug report
title: ''
labels: 'bug'
assignees: ''
---
Thanks for submitting a bug report. Please provide the following information:
**A description of the problem**
Describe the problem here.
**cheat version info**
Please paste the output of `cheat -v` here.
**cheat configuration info**
If your bug pertains to how cheatsheets are loaded and/or displayed, please
paste here the following information:
1. The output of `cheat -d`
2. The contents of your `conf.yml` file

@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: 'enhancement'
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

11
.github/dependabot.yml vendored Normal file

@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
ignore:
- dependency-name: github.com/alecthomas/chroma
versions:
- 0.9.1

46
.github/workflows/build.yml vendored Normal file

@ -0,0 +1,46 @@
---
name: Go
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
# TODO: is it possible to DRY out these jobs? Aside from `runs-on`, they are
# identical.
# See: https://github.com/actions/runner/issues/1182
build-linux:
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19
- name: Set up Revive (linter)
run: go get -u github.com/boyter/scc github.com/mgechev/revive
env:
GO111MODULE: "off"
- name: Build
run: make build
- name: Test
run: make test
build-osx:
runs-on: [macos-latest]
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19
- name: Set up Revive (linter)
run: go get -u github.com/boyter/scc github.com/mgechev/revive
env:
GO111MODULE: "off"
- name: Build
run: make build
- name: Test
run: make test

30
.github/workflows/codeql-analysis.yml vendored Normal file

@ -0,0 +1,30 @@
---
name: CodeQL
on:
push:
branches: [master]
pull_request:
branches: [master]
schedule:
- cron: '45 23 * * 0'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [go]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

19
.github/workflows/homebrew.yml vendored Normal file

@ -0,0 +1,19 @@
---
name: homebrew
on:
push:
tags: '*'
jobs:
homebrew:
name: Bump Homebrew formula
runs-on: ubuntu-latest
steps:
- uses: mislav/bump-homebrew-formula-action@v1
with:
# A PR will be sent to github.com/Homebrew/homebrew-core to update
# this formula:
formula-name: cheat
env:
COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}

5
.gitignore vendored

@ -1,5 +1,2 @@
*.pyc
MANIFEST
build
cheat.egg-info
dist
tags

@ -1,29 +1,48 @@
Contributing
CONTRIBUTING
============
If you would like to contribute cheetsheets or program functionality, please
fork this repository, make your changes, and submit a pull request against the
`master` branch.
Do you want to contribute to `cheat`? There are a few ways to help:
#### Submit a cheatsheet ####
Do you have a witty bash one-liner to share? [Open a pull-request][pr] against
the [cheatsheets][] repository. (The `cheat` executable source code lives in
[cheat/cheat][cheat]. Cheatsheet content lives in
[cheat/cheatsheets][cheatsheets].)
#### Report a bug ####
Did you find a bug? Report it in the [issue tracker][issues]. (But before you
do, please look through the open issues to make sure that it hasn't already
been reported.)
#### Add a feature ####
Do you have a feature that you'd like to contribute? Propose it in the [issue
tracker][issues] to discuss with the maintainer whether it would be considered
for merging.
`cheat` is mostly mature and feature-complete, but may still have some room for
new features. See [HACKING.md][hacking] for a quick-start guide to `cheat`
development.
#### Add documentation ####
Did you encounter features, bugs, edge-cases, use-cases, or environment
considerations that were undocumented or under-documented? Add them to the
[wiki][]. (You may also open a pull-request against the `README`, if
appropriate.)
Do you enjoy technical writing or proofreading? Help keep the documentation
error-free and well-organized.
#### Spread the word ####
Are you unable to do the above, but still want to contribute? You can help
`cheat` simply by telling others about it. Share it with friends and coworkers
that might benefit from using it.
#### Pull Requests ####
Please open all pull-requests against the `develop` branch.
## Python standards ##
Python code should conform to [PEP 8][].
## Cheatsheet Format ##
Please pattern your cheatsheets after the following:
```sh
# To extract an uncompressed archive:
tar -xvf /path/to/foo.tar
# To create an uncompressed archive:
tar -cvf /path/to/foo.tar /path/to/foo/
# To extract a .gz archive:
tar -xzvf /path/to/foo.tgz
```
If you are submitting a cheatsheet that contains side-by-side columns of text,
please align the columns using spaces rather than tabs.
[PEP 8]: http://legacy.python.org/dev/peps/pep-0008/
[cheat]: https://github.com/cheat/cheat
[cheatsheets]: https://github.com/cheat/cheatsheets
[hacking]: HACKING.md
[issues]: https://github.com/cheat/cheat/issues
[pr]: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork
[wiki]: https://github.com/cheat/cheat/wiki

8
Dockerfile Normal file

@ -0,0 +1,8 @@
# NB: this image isn't used anywhere in the build pipeline. It exists to
# conveniently facilitate ad-hoc experimentation in a sandboxed environment
# during development.
FROM golang:1.15-alpine
RUN apk add git less make
WORKDIR /app

57
HACKING.md Normal file

@ -0,0 +1,57 @@
Hacking
=======
The following is a quickstart guide for developing `cheat`.
## 1. Install system dependencies
Before you begin, you must install a handful of system dependencies. The
following are required, and must be available on your `PATH`:
- `git`
- `go` (>= 1.17 is recommended)
- `make`
The following dependencies are optional:
- `docker`
- `pandoc` (necessary to generate a `man` page)
## 2. Install utility applications
Run `make setup` to install `scc` and `revive`, which are used by various
`make` targets.
## 3. Development workflow
After your environment has been configured, your development workflow will
resemble the following:
1. Make changes to the `cheat` source code.
2. Run `make test` to run unit-tests.
3. Fix compiler errors and failing tests as necessary.
4. Run `make`. A `cheat` executable will be written to the `dist` directory.
5. Use the new executable by running `dist/cheat <command>`.
6. Run `make install` to install `cheat` to your `PATH`.
7. Run `make build-release` to build cross-platform binaries in `dist`.
8. Run `make clean` to clean the `dist` directory when desired.
You may run `make help` to see a list of available `make` commands.
### Developing with docker
It may be useful to test your changes within a pristine environment. An
Alpine-based docker container has been provided for that purpose.
If you would like to build the docker container, run:
```sh
make docker-setup
```
To shell into the container, run:
```sh
make docker-sh
```
The `cheat` source code will be mounted at `/app` within the container.
If you would like to destroy this container, you may run:
```sh
make distclean
```
[go]: https://go.dev/

79
INSTALLING.md Normal file

@ -0,0 +1,79 @@
Installing
==========
`cheat` has no runtime dependencies. As such, installing it is generally
straightforward. There are a few methods available:
### Install manually
#### Unix-like
On Unix-like systems, you may simply paste the following snippet into your terminal:
```sh
cd /tmp \
&& wget https://github.com/cheat/cheat/releases/download/4.4.2/cheat-linux-amd64.gz \
&& gunzip cheat-linux-amd64.gz \
&& chmod +x cheat-linux-amd64 \
&& sudo mv cheat-linux-amd64 /usr/local/bin/cheat
```
You may need to need to change the version number (`4.4.2`) and the archive
(`cheat-linux-amd64.gz`) depending on your platform.
See the [releases page][releases] for a list of supported platforms.
#### Windows
TODO: community support is requested here. Please open a PR if you'd like to
contribute installation instructions for Windows.
### Install via `go install`
If you have `go` version `>=1.17` available on your `PATH`, you can install
`cheat` via `go install`:
```sh
go install github.com/cheat/cheat/cmd/cheat@latest
```
### Install via package manager
Several community-maintained packages are also available:
Package manager | Package(s)
---------------- | -----------
aur | [cheat][pkg-aur-cheat], [cheat-bin][pkg-aur-cheat-bin]
brew | [cheat][pkg-brew]
docker | [docker-cheat][pkg-docker]
nix | [nixos.cheat][pkg-nix]
snap | [cheat][pkg-snap]
<!--[pacman][] |-->
## Configuring
Three things must be done before you can use `cheat`:
1. A config file must be generated
2. [`cheatpaths`][cheatpaths] must be configured
3. [Community cheatsheets][community] must be downloaded
On first run, `cheat` will run an installer that will do all of the above
automatically. After the installer is complete, it is strongly advised that you
view the configuration file that was generated, as you may want to change some
of its default values (to enable colorization, change the paginator, etc).
### conf.yml ###
`cheat` is configured by a YAML file that will be auto-generated on first run.
By default, the config file is assumed to exist on an XDG-compliant
configuration path like `~/.config/cheat/conf.yml`. If you would like to store
it elsewhere, you may export a `CHEAT_CONFIG_PATH` environment variable that
specifies its path:
```sh
export CHEAT_CONFIG_PATH="~/.dotfiles/cheat/conf.yml"
```
[cheatpaths]: README.md#cheatpaths
[community]: https://github.com/cheat/cheatsheets/
[pkg-aur-cheat-bin]: https://aur.archlinux.org/packages/cheat-bin
[pkg-aur-cheat]: https://aur.archlinux.org/packages/cheat
[pkg-brew]: https://formulae.brew.sh/formula/cheat
[pkg-docker]: https://github.com/bannmann/docker-cheat
[pkg-nix]: https://search.nixos.org/packages?channel=unstable&show=cheat&from=0&size=50&sort=relevance&type=packages&query=cheat
[pkg-snap]: https://snapcraft.io/cheat
[releases]: https://github.com/cheat/cheat/releases

@ -1,2 +0,0 @@
This program is dual-licensed under the MIT and GPL3 licenses. See the licenses
directory for the license text in full.

@ -1,4 +1,4 @@
The MIT License (MIT) Copyright (c) 2016 Chris Allen Lane
Copyright 2013 Christopher Allen Lane
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in

@ -1,6 +0,0 @@
include CHANGELOG
include CONTRIBUTING.md
include LICENSE
include README.md
include licenses/gpl-3.txt
include licenses/mit.txt

218
Makefile Normal file

@ -0,0 +1,218 @@
# paths
makefile := $(realpath $(lastword $(MAKEFILE_LIST)))
cmd_dir := ./cmd/cheat
dist_dir := ./dist
# executables
CAT := cat
COLUMN := column
CTAGS := ctags
DOCKER := docker
GO := go
GREP := grep
GZIP := gzip --best
LINT := revive
MAN := man
MKDIR := mkdir -p
PANDOC := pandoc
RM := rm
SCC := scc
SED := sed
SORT := sort
ZIP := zip -m
docker_image := cheat-devel:latest
# build flags
BUILD_FLAGS := -ldflags="-s -w" -mod vendor -trimpath
GOBIN :=
TMPDIR := /tmp
# release binaries
releases := \
$(dist_dir)/cheat-darwin-amd64 \
$(dist_dir)/cheat-linux-386 \
$(dist_dir)/cheat-linux-amd64 \
$(dist_dir)/cheat-linux-arm5 \
$(dist_dir)/cheat-linux-arm6 \
$(dist_dir)/cheat-linux-arm64 \
$(dist_dir)/cheat-linux-arm7 \
$(dist_dir)/cheat-netbsd-amd64 \
$(dist_dir)/cheat-openbsd-amd64 \
$(dist_dir)/cheat-solaris-amd64 \
$(dist_dir)/cheat-windows-amd64.exe
## build: build an executable for your architecture
.PHONY: build
build: | clean $(dist_dir) generate fmt lint vet vendor man
$(GO) build $(BUILD_FLAGS) -o $(dist_dir)/cheat $(cmd_dir)
## build-release: build release executables
.PHONY: build-release
build-release: $(releases)
# cheat-darwin-amd64
$(dist_dir)/cheat-darwin-amd64: prepare
GOARCH=amd64 GOOS=darwin \
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
# cheat-linux-386
$(dist_dir)/cheat-linux-386: prepare
GOARCH=386 GOOS=linux \
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
# cheat-linux-amd64
$(dist_dir)/cheat-linux-amd64: prepare
GOARCH=amd64 GOOS=linux \
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
# cheat-linux-arm5
$(dist_dir)/cheat-linux-arm5: prepare
GOARCH=arm GOOS=linux GOARM=5 \
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
# cheat-linux-arm6
$(dist_dir)/cheat-linux-arm6: prepare
GOARCH=arm GOOS=linux GOARM=6 \
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
# cheat-linux-arm7
$(dist_dir)/cheat-linux-arm7: prepare
GOARCH=arm GOOS=linux GOARM=7 \
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
# cheat-linux-arm64
$(dist_dir)/cheat-linux-arm64: prepare
GOARCH=arm64 GOOS=linux \
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
# cheat-netbsd-amd64
$(dist_dir)/cheat-netbsd-amd64: prepare
GOARCH=amd64 GOOS=netbsd \
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
# cheat-openbsd-amd64
$(dist_dir)/cheat-openbsd-amd64: prepare
GOARCH=amd64 GOOS=openbsd \
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
# cheat-plan9-amd64
$(dist_dir)/cheat-plan9-amd64: prepare
GOARCH=amd64 GOOS=plan9 \
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
# cheat-solaris-amd64
$(dist_dir)/cheat-solaris-amd64: prepare
GOARCH=amd64 GOOS=solaris \
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
# cheat-windows-amd64
$(dist_dir)/cheat-windows-amd64.exe: prepare
GOARCH=amd64 GOOS=windows \
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(ZIP) $@.zip $@ -j
# ./dist
$(dist_dir):
$(MKDIR) $(dist_dir)
.PHONY: generate
generate:
$(GO) generate $(cmd_dir)
## install: build and install cheat on your PATH
.PHONY: install
install: build
$(GO) install $(BUILD_FLAGS) $(GOBIN) $(cmd_dir)
## clean: remove compiled executables
.PHONY: clean
clean:
$(RM) -f $(dist_dir)/* $(cmd_dir)/str_config.go $(cmd_dir)/str_usage.go
## distclean: remove the tags file
.PHONY: distclean
distclean:
$(RM) -f tags
@$(DOCKER) image rm -f $(docker_image)
## setup: install revive (linter) and scc (sloc tool)
.PHONY: setup
setup:
GO111MODULE=off $(GO) get -u github.com/boyter/scc github.com/mgechev/revive
## sloc: count "semantic lines of code"
.PHONY: sloc
sloc:
$(SCC) --exclude-dir=vendor
## tags: build a tags file
.PHONY: tags
tags:
$(CTAGS) -R --exclude=vendor --languages=go
## man: build a man page
# NB: pandoc may not be installed, so we're ignoring this error on failure
.PHONY: man
man:
-$(PANDOC) -s -t man doc/cheat.1.md -o doc/cheat.1
## vendor: download, tidy, and verify dependencies
.PHONY: vendor
vendor:
$(GO) mod vendor && $(GO) mod tidy && $(GO) mod verify
## vendor-update: update vendored dependencies
vendor-update:
$(GO) get -t -u ./... && $(GO) mod vendor && $(GO) mod tidy && $(GO) mod verify
## fmt: run go fmt
.PHONY: fmt
fmt:
$(GO) fmt ./...
## lint: lint go source files
.PHONY: lint
lint: vendor
$(LINT) -exclude vendor/... ./...
## vet: vet go source files
.PHONY: vet
vet:
$(GO) vet ./...
## test: run unit-tests
.PHONY: test
test:
$(GO) test ./...
## coverage: generate a test coverage report
.PHONY: coverage
coverage:
$(GO) test ./... -coverprofile=$(TMPDIR)/cheat-coverage.out && \
$(GO) tool cover -html=$(TMPDIR)/cheat-coverage.out
## check: format, lint, vet, vendor, and run unit-tests
.PHONY: check
check: | vendor fmt lint vet test
.PHONY: prepare
prepare: | clean $(dist_dir) generate vendor fmt lint vet test
## docker-setup: create a docker image for use during development
.PHONY: docker-setup
docker-setup:
$(DOCKER) build -t $(docker_image) -f Dockerfile .
## docker-sh: shell into the docker development container
.PHONY: docker-sh
docker-sh:
$(DOCKER) run -v $(shell pwd):/app -ti $(docker_image) /bin/ash
## help: display this help text
.PHONY: help
help:
@$(CAT) $(makefile) | \
$(SORT) | \
$(GREP) "^##" | \
$(SED) 's/## //g' | \
$(COLUMN) -t -s ':'

221
README.md

@ -1,7 +1,9 @@
[![PyPI](https://img.shields.io/pypi/v/cheat.svg)](https://pypi.python.org/pypi/cheat/)
![Workflow status](https://github.com/cheat/cheat/actions/workflows/build.yml/badge.svg)
cheat
=====
`cheat` allows you to create and view interactive cheatsheets on the
command-line. It was designed to help remind \*nix system administrators of
options for commands that they use frequently, but not frequently enough to
@ -9,6 +11,8 @@ remember.
![The obligatory xkcd](http://imgs.xkcd.com/comics/tar.png 'The obligatory xkcd')
Use `cheat` with [cheatsheets][].
Example
-------
@ -19,10 +23,10 @@ Google, you may run:
cheat tar
```
You will be presented with a cheatsheet resembling:
You will be presented with a cheatsheet resembling the following:
```sh
# To extract an uncompressed archive:
# To extract an uncompressed archive:
tar -xvf '/path/to/foo.tar'
# To extract a .gz archive:
@ -38,111 +42,152 @@ tar -xjvf '/path/to/foo.tgz'
tar -cjvf '/path/to/foo.tgz' '/path/to/foo/'
```
To see what cheatsheets are available, run `cheat -l`.
Usage
-----
To view a cheatsheet:
```sh
cheat tar # a "top-level" cheatsheet
cheat foo/bar # a "nested" cheatsheet
```
To edit a cheatsheet:
```sh
cheat -e tar # opens the "tar" cheatsheet for editing, or creates it if it does not exist
cheat -e foo/bar # nested cheatsheets are accessed like this
```
To view the configured cheatpaths:
```sh
cheat -d
```
To list all available cheatsheets:
```sh
cheat -l
```
To list all cheatsheets that are tagged with "networking":
```sh
cheat -l -t networking
```
To list all cheatsheets on the "personal" path:
```sh
cheat -l -p personal
```
To search for the phrase "ssh" among cheatsheets:
```sh
cheat -s ssh
```
To search (by regex) for cheatsheets that contain an IP address:
```sh
cheat -r -s '(?:[0-9]{1,3}\.){3}[0-9]{1,3}'
```
Flags may be combined in intuitive ways. Example: to search sheets on the
"personal" cheatpath that are tagged with "networking" and match a regex:
```sh
cheat -p personal -t networking --regex -s '(?:[0-9]{1,3}\.){3}[0-9]{1,3}'
```
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`:
For installation and configuration instructions, see [INSTALLING.md][].
```sh
[sudo] pip install cheat
```
[Other installation methods are available][installing].
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.
Cheatsheets are stored in the `~/.cheat/` directory, and are named on a
per-keyphrase basis. In other words, the content for the `tar` cheatsheet lives
in the `~/.cheat/tar` file.
Provided that you have a `CHEAT_EDITOR`, `VISUAL`, or `EDITOR` environment
variable set, you may edit cheatsheets with:
```sh
cheat -e foo
```
If the `foo` cheatsheet already exists, it will be opened for editing.
Otherwise, it will be created automatically.
After you've customized your cheatsheets, I urge you to track `~/.cheat/` along
with your [dotfiles][].
Configuring
Cheatsheets
-----------
### Setting a DEFAULT_CHEAT_DIR ###
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:
Cheatsheets are plain-text files with no file extension, and are named
according to the command used to view them:
```sh
export DEFAULT_CHEAT_DIR='/path/to/my/cheats'
cheat tar # file is named "tar"
cheat foo/bar # file is named "bar", in a "foo" subdirectory
```
### Setting a CHEATPATH ###
You can additionally instruct `cheat` to look for cheatsheets in other
directories by exporting a `CHEATPATH` environment variable:
Cheatsheet text may optionally be preceeded by a YAML frontmatter header that
assigns tags and specifies syntax:
```sh
export CHEATPATH='/path/to/my/cheats'
```
---
syntax: javascript
tags: [ array, map ]
---
// To map over an array:
const squares = [1, 2, 3, 4].map(x => x * x);
```
You may, of course, append multiple directories to your `CHEATPATH`:
The `cheat` executable includes no cheatsheets, but [community-sourced
cheatsheets are available][cheatsheets]. You will be asked if you would like to
install the community-sourced cheatsheets the first time you run `cheat`.
```sh
export CHEATPATH="$CHEATPATH:/path/to/more/cheats"
Cheatpaths
----------
Cheatsheets are stored on "cheatpaths", which are directories that contain
cheatsheets. Cheatpaths are specified in the `conf.yml` file.
It can be useful to configure `cheat` against multiple cheatpaths. A common
pattern is to store cheatsheets from multiple repositories on individual
cheatpaths:
```yaml
# conf.yml:
# ...
cheatpaths:
- name: community # a name for the cheatpath
path: ~/documents/cheat/community # the path's location on the filesystem
tags: [ community ] # these tags will be applied to all sheets on the path
readonly: true # if true, `cheat` will not create new cheatsheets here
- name: personal
path: ~/documents/cheat/personal # this is a separate directory and repository than above
tags: [ personal ]
readonly: false # new sheets may be written here
# ...
```
You may view which directories are on your `CHEATPATH` with `cheat -d`.
The `readonly` option instructs `cheat` not to edit (or create) any cheatsheets
on the path. This is useful to prevent merge-conflicts from arising on upstream
cheatsheet repositories.
### Enabling Syntax Highlighting ###
`cheat` can optionally apply syntax highlighting to your cheatsheets. To enable
syntax highlighting, export a `CHEATCOLORS` environment variable:
If a user attempts to edit a cheatsheet on a read-only cheatpath, `cheat` will
transparently copy that sheet to a writeable directory before opening it for
editing.
```sh
export CHEATCOLORS=true
```
### Directory-scoped Cheatpaths ###
At times, it can be useful to closely associate cheatsheets with a directory on
your filesystem. `cheat` facilitates this by searching for a `.cheat` folder in
the current working directory. If found, the `.cheat` directory will
(temporarily) be added to the cheatpaths.
#### Specifying a Syntax Highlighter ####
You may manually specify which syntax highlighter to use for each cheatsheet by
wrapping the sheet's contents in a [Github-Flavored Markdown code-fence][gfm].
Autocompletion
--------------
Shell autocompletion is currently available for `bash`, `fish`, and `zsh`. Copy
the relevant [completion script][completions] into the appropriate directory on
your filesystem to enable autocompletion. (This directory will vary depending
on operating system and shell specifics.)
Example:
Additionally, `cheat` supports enhanced autocompletion via integration with
[fzf][]. To enable `fzf` integration:
<pre>
```sql
-- to select a user by ID
SELECT *
FROM Users
WHERE id = 100
```
</pre>
1. Ensure that `fzf` is available on your `$PATH`
2. Set an envvar: `export CHEAT_USE_FZF=true`
If no syntax highlighter is specified, the `bash` highlighter will be used by
default.
See Also:
---------
- [Enabling Command-line Autocompletion][autocompletion]
- [Related Projects][related-projects]
[autocompletion]: https://github.com/chrisallenlane/cheat/wiki/Enabling-Command-line-Autocompletion
[dotfiles]: http://dotfiles.github.io/
[gfm]: https://help.github.com/articles/creating-and-highlighting-code-blocks/
[installing]: https://github.com/chrisallenlane/cheat/wiki/Installing
[related-projects]: https://github.com/chrisallenlane/cheat/wiki/Related-Projects
[INSTALLING.md]: INSTALLING.md
[Releases]: https://github.com/cheat/cheat/releases
[cheatsheets]: https://github.com/cheat/cheatsheets
[completions]: https://github.com/cheat/cheat/tree/master/scripts
[fzf]: https://github.com/junegunn/fzf
[go]: https://golang.org

@ -1,65 +0,0 @@
#!/usr/bin/env python
"""cheat
Create and view cheatsheets on the command line.
Usage:
cheat <cheatsheet>
cheat -e <cheatsheet>
cheat -s <keyword>
cheat -l
cheat -d
cheat -v
Options:
-d --directories List directories on CHEATPATH
-e --edit Edit cheatsheet
-l --list List cheatsheets
-s --search Search cheatsheets for <keyword>
-v --version Print the version number
Examples:
To view the `tar` cheatsheet:
cheat tar
To edit (or create) the `foo` cheatsheet:
cheat -e foo
To list all available cheatsheets:
cheat -l
To search for "ssh" among all cheatsheets:
cheat -s ssh
"""
# require the dependencies
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.3.1')
# list directories
if options['--directories']:
print("\n".join(sheets.paths()))
# list cheatsheets
elif options['--list']:
print(sheets.list())
# create/edit cheatsheet
elif options['--edit']:
sheet.create_or_edit(options['<cheatsheet>'])
# search among the cheatsheets
elif options['--search']:
print(colorize(sheets.search(options['<keyword>'])))
# print the cheatsheet
else:
print(colorize(sheet.read(options['<cheatsheet>'])))

92
build/embed.go Normal file

@ -0,0 +1,92 @@
//go:build ignore
// +build ignore
// This script embeds `docopt.txt and `conf.yml` into the binary during at
// build time.
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
)
func main() {
// get the cwd
cwd, err := os.Getwd()
if err != nil {
log.Fatal(err)
}
// get the project root
root, err := filepath.Abs(cwd + "../../../")
if err != nil {
log.Fatal(err)
}
// specify template file information
type file struct {
In string
Out string
Method string
}
// enumerate the template files to process
files := []file{
file{
In: "cmd/cheat/docopt.txt",
Out: "cmd/cheat/str_usage.go",
Method: "usage"},
file{
In: "configs/conf.yml",
Out: "cmd/cheat/str_config.go",
Method: "configs"},
}
// iterate over each static file
for _, file := range files {
// delete the outfile
os.Remove(filepath.Join(root, file.Out))
// read the static template
bytes, err := ioutil.ReadFile(filepath.Join(root, file.In))
if err != nil {
log.Fatal(err)
}
// render the template
data := template(file.Method, string(bytes))
// write the file to the specified outpath
spath := filepath.Join(root, file.Out)
err = ioutil.WriteFile(spath, []byte(data), 0644)
if err != nil {
log.Fatal(err)
}
}
}
// template packages the
func template(method string, body string) string {
// specify the template string
t := `package main
// Code generated .* DO NOT EDIT.
import (
"strings"
)
func %s() string {
return strings.TrimSpace(%s)
}
`
return fmt.Sprintf(t, method, "`"+body+"`")
}

@ -1,3 +0,0 @@
from . import sheet
from . import sheets
from . import utils

@ -1,9 +0,0 @@
function _cheat_autocomplete {
sheets=$(cheat -l | cut -d' ' -f1)
COMPREPLY=()
if [ $COMP_CWORD = 1 ]; then
COMPREPLY=(`compgen -W "$sheets" -- $2`)
fi
}
complete -F _cheat_autocomplete cheat

@ -1,12 +0,0 @@
#completion for cheat
complete -c cheat -s h -l help -f -x --description "Display help and exit"
complete -c cheat -l edit -f -x --description "Edit <cheatsheet>"
complete -c cheat -s e -f -x --description "Edit <cheatsheet>"
complete -c cheat -s l -l list -f -x --description "List all available cheatsheets"
complete -c cheat -s d -l cheat-directories -f -x --description "List all current cheat dirs"
complete -c cheat --authoritative -f
for cheatsheet in (cheat -l | cut -d' ' -f1)
complete -c cheat -a "$cheatsheet"
complete -c cheat -o e -a "$cheatsheet"
complete -c cheat -o '-edit' -a "$cheatsheet"
end

@ -1,5 +0,0 @@
#compdef cheat
declare -a cheats
cheats=$(cheat -l | cut -d' ' -f1)
_arguments "1:cheats:(${cheats})" && return 0

@ -1,29 +0,0 @@
7z
A file archiver with highest compression ratio
Args:
a add
d delete
e extract
l list
t test
u update
x extract with full paths
Example:
7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on archive.7z dir1
-t7z 7z archive
-m0=lzma lzma method
-mx=9 level of compression = 9 (ultra)
-mfb=64 number of fast bytes for lzma = 64
-md=32m dictionary size = 32 Mb
-ms=on solid archive = on
7z exit codes:
0 normal (no errors or warnings)
1 warning (non-fatal errors)
2 fatal error
7 bad cli arguments
8 not enough memory for operation
255 process was interrupted

@ -1,4 +0,0 @@
import os
def sheets_dir():
return os.path.split(__file__)

@ -1,5 +0,0 @@
# send 100 requests with a concurency of 50 requests to an URL
ab -n 100 -c 50 http://www.example.com/
# send requests during 30 seconds with a concurency of 50 requests to an URL
ab -t 30 -c 50 URL http://www.example.com/

@ -1,5 +0,0 @@
# Show a list of your current shell aliases
alias
# Map `ll` to `ls -l` (Can be used per session or put inside a shell config file)
alias ll='ls -l'

@ -1,72 +0,0 @@
# 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

@ -1,14 +0,0 @@
# Install a package
apk add $package
# Remove a package
apk del $package
# Update repos
apk update
# Upgrade all packages
apk upgrade
# Find a package
apk search $package

@ -1,18 +0,0 @@
# Desc: Apparmor will protect the system by confining programs to a limited set of resources.
# To activate a profile:
sudo aa-enforce usr.bin.firefox
# OR
export _PROFILE_='usr.bin.firefox' sudo $(rm /etc/apparmor.d/disable/$_PROFILE_ ; cat /etc/apparmor.d/$_PROFILE_ | apparmor_parser -a )
# TO disable a profile:
sudo aa-disable usr.bin.firefox
# OR
export _PROFILE_='usr.bin.firefox' sudo $(ln -s /etc/apparmor.d/$_PROFILE_ /etc/apparmor.d/disable/ && apparmor_parser -R /etc/apparmor.d/$_PROFILE_)
# To list profiles loaded:
sudo aa-status
# OR
sudo apparmor_status
# List of profiles aviables: /etc/apparmor.d/

@ -1,23 +0,0 @@
# To search a package:
apt search package
# To show package informations:
apt show package
# To fetch package list:
apt update
# To download and install updates without installing new package:
apt upgrade
# To download and install the updates AND install new necessary packages:
apt dist-upgrade
# Full command:
apt update && apt dist-upgrade
# To install a new package(s):
apt install package(s)
# To uninstall package(s)
apt remove package(s)

@ -1,12 +0,0 @@
# To search for apt packages:
apt-cache search "whatever"
# To display package records for the named package(s):
apt-cache show pkg(s)
# To display reverse dependencies of a package
apt-cache rdepends package_name
# To display package versions, reverse dependencies and forward dependencies
# of a package
apt-cache showpkg package_name

@ -1,28 +0,0 @@
# Desc: Allows to update the operating system
# To fetch package list
apt-get update
# To download and install updates without installing new package.
apt-get upgrade
# To download and install the updates AND install new necessary packages
apt-get dist-upgrade
# Full command:
apt-get update && apt-get dist-upgrade
# To install a new package(s)
apt-get install package(s)
# Download a package without installing it. (The package will be downloaded in your current working dir)
apt-get download modsecurity-crs
# Change Cache dir and archive dir (where .deb are stored).
apt-get -o Dir::Cache="/path/to/destination/dir/" -o Dir::Cache::archives="./" install ...
# Show apt-get installed packages.
grep 'install ' /var/log/dpkg.log
# Silently keep old configuration during batch updates
apt-get update -o DPkg::Options::='--force-confold' ...

@ -1,15 +0,0 @@
# To search for packages:
aptitude search "whatever"
# To display package records for the named package(s):
aptitude show pkg(s)
# To install a package:
aptitude install package
# To remove a package:
aptitude remove package
# To remove unnecessary package:
aptitude autoclean

@ -1,12 +0,0 @@
# Just download a file
# The url can be a http(s), ftp, .torrent file or even a magnet link
aria2c <url>
# To prevent downloading the .torrent file
aria2c --follow-torrent=mem <url>
# Download 1 file at a time (-j)
# continuing (-c) any partially downloaded ones
# to the directory specified (-d)
# reading urls from the file (-i)
aria2c -j 1 -c -d ~/Downloads -i /path/to/file

@ -1,22 +0,0 @@
# To show some text in ASCII Art:
figlet Cheat
# ____ _ _
# / ___| |__ ___ __ _| |_
#| | | '_ \ / _ \/ _` | __|
#| |___| | | | __/ (_| | |_
# \____|_| |_|\___|\__,_|\__|
#
# To have some text with color and other options:
# Show with a border
toilet -F border Cheat
# Basic show (filled)
toilet Cheat
# mmm # m
# m" " # mm mmm mmm mm#mm
# # #" # #" # " # #
# # # # #"""" m"""# #
# "mmm" # # "#mm" "mm"# "mm
#

@ -1,17 +0,0 @@
# To connect to a running Asterisk session:
asterisk -rvvv
# To issue a command to Asterisk from the shell:
asterisk -rx "<command>"
# To originate an echo call from a SIP trunk on an Asterisk server, to a specified number:
asterisk -rx "channel originate SIP/<trunk>/<number> application echo"
# To print out the details of SIP accounts:
asterisk -rx "sip show peers"
# To print out the passwords of SIP accounts:
asterisk -rx "sip show users"
# To print out the current active channels:
asterisk -rx "core show channels"

@ -1,17 +0,0 @@
# To schedule a one time task
at {time}
{command 0}
{command 1}
Ctrl-d
# {time} can be either
now | midnight | noon | teatime (4pm)
HH:MM
now + N {minutes | hours | days | weeks}
MM/DD/YY
# To list pending jobs
atq
# To remove a job (use id from atq)
atrm {id}

@ -1,11 +0,0 @@
# sum integers from a file or stdin, one integer per line:
printf '1\n2\n3\n' | awk '{ sum += $1} END {print sum}'
# using specific character as separator to sum integers from a file or stdin
printf '1:2:3' | awk -F ":" '{print $1+$2+$3}'
# print a multiplication table
seq 9 | sed 'H;g' | awk -v RS='' '{for(i=1;i<=NF;i++)printf("%dx%d=%d%s", i, NR, i*NR, i==NR?"\n":"\t")}'
# Specify output separator character
printf '1 2 3' | awk 'BEGIN {OFS=":"}; {print $1,$2,$3}'

@ -1,27 +0,0 @@
# To implement a for loop:
for file in *;
do
echo $file found;
done
# To implement a case command:
case "$1"
in
0) echo "zero found";;
1) echo "one found";;
2) echo "two found";;
3*) echo "something beginning with 3 found";;
esac
# Turn on debugging:
set -x
# Turn off debugging:
set +x
# Retrieve N-th piped command exit status
printf 'foo' | fgrep 'foo' | sed 's/foo/bar/'
echo ${PIPESTATUS[0]} # replace 0 with N
# Lock file:
( set -o noclobber; echo > my.lock ) || echo 'Failed to create lock file'

@ -1,26 +0,0 @@
# Install a package locally
bower install <package-name>
# Install a package locally directly from github
bower install <user>/<repo>
# Install a specific package locally
bower install <package-name>#<version>
# Install a package locally and save installed package into bower.json
bower install <package-name> --save
# Retrieve info of a particular package
bower info <package-name>
# List local packages
bower list
# Search for a package by name
bower search <package-name>
# Update a package to their newest version
bower update <package-name>
# Remove a local package
bower uninstall <package-name>

@ -1,11 +0,0 @@
# compress foo -> foo.bz2
bzip2 -z foo
# decompress foo.bz2 -> foo
bzip2 -d foo.bz2
# compress foo to stdout
bzip2 -zc foo > foo.bz2
# decompress foo.bz2 to stdout
bzip2 -dc foo.bz2

@ -1,8 +0,0 @@
# Display the contents of a file
cat /path/to/foo
# Display contents with line numbers
cat -n /path/to/foo
# Display contents with line numbers (blank lines excluded)
cat -b /path/to/foo

@ -1,11 +0,0 @@
#Go to the given directory
cd path/to/directory
#Go to home directory of current user
cd
#Go up to the parent of the current directory
cd ..
#Go to the previously chosen directory
cd -

@ -1,14 +0,0 @@
# To see example usage of a program:
cheat <command>
# To edit a cheatsheet
cheat -e <command>
# To list available cheatsheets
cheat -l
# To search available cheatsheets
cheat -s <command>
# To get the current `cheat' version
cheat -v

@ -1,36 +0,0 @@
# Add execute for all (myscript.sh)
chmod a+x myscript.sh
# Set user to read/write/execute, group/global to read only (myscript.sh), symbolic mode
chmod u=rwx, go=r myscript.sh
# Remove write from user/group/global (myscript.sh), symbolic mode
chmod a-w myscript.sh
# Remove read/write/execute from user/group/global (myscript.sh), symbolic mode
chmod = myscript.sh
# Set user to read/write and group/global read (myscript.sh), octal notation
chmod 644 myscript.sh
# Set user to read/write/execute and group/global read/execute (myscript.sh), octal notation
chmod 755 myscript.sh
# Set user/group/global to read/write (myscript.sh), octal notation
chmod 666 myscript.sh
# Roles
u - user (owner of the file)
g - group (members of file's group)
o - global (all users who are not owner and not part of group)
a - all (all 3 roles above)
# Numeric representations
7 - full (rwx)
6 - read and write (rw-)
5 - read and execute (r-x)
4 - read only (r--)
3 - write and execute (-wx)
2 - write only (-w-)
1 - execute only (--x)
0 - none (---)

@ -1,11 +0,0 @@
# Change file owner
chown user file
# Change file owner and group
chown user:group file
# Change owner recursively
chown -R user directory
# Change ownership to match another file
chown --reference=/path/to/ref_file file

@ -1,19 +0,0 @@
# To resize an image to a fixed width and proportional height:
convert original-image.jpg -resize 100x converted-image.jpg
# To resize an image to a fixed height and proportional width:
convert original-image.jpg -resize x100 converted-image.jpg
# To resize an image to a fixed width and height:
convert original-image.jpg -resize 100x100 converted-image.jpg
# To resize an image and simultaneously change its file type:
convert original-image.jpg -resize 100x converted-image.png
# To resize all of the images within a directory:
# To implement a for loop:
for file in `ls original/image/path/`;
do new_path=${file%.*};
new_file=`basename $new_path`;
convert $file -resize 150 conerted/image/path/$new_file.png;
done

@ -1,11 +0,0 @@
# Create a copy of a file
cp ~/Desktop/foo.txt ~/Downloads/foo.txt
# Create a copy of a directory
cp -r ~/Desktop/cruise_pics/ ~/Pictures/
# Create a copy but ask to overwrite if the destination file already exists
cp -i ~/Desktop/foo.txt ~/Documents/foo.txt
# Create a backup file with date
cp foo.txt{,."$(date +%Y%m%d-%H%M%S)"}

@ -1,132 +0,0 @@
# 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

@ -1,22 +0,0 @@
# set a shell
SHELL=/bin/bash
# crontab format
* * * * * command_to_execute
- - - - -
| | | | |
| | | | +- day of week (0 - 7) (where sunday is 0 and 7)
| | | +--- month (1 - 12)
| | +----- day (1 - 31)
| +------- hour (0 - 23)
+--------- minute (0 - 59)
# example entries
# every 15 min
*/15 * * * * /home/user/command.sh
# every midnight
0 0 * * * /home/user/command.sh
# every Saturday at 8:05 AM
5 8 * * 6 /home/user/command.sh

@ -1,8 +0,0 @@
# open encrypted partition /dev/sdb1 (reachable at /dev/mapper/backup)
cryptsetup open --type luks /dev/sdb1 backup
# open encrypted partition /dev/sdb1 using a keyfile (reachable at /dev/mapper/hdd)
cryptsetup open --type luks --key-file hdd.key /dev/sdb1 hdd
# close luks container at /dev/mapper/hdd
cryptsetup close hdd

@ -1,5 +0,0 @@
# Split a file based on pattern
csplit input.file '/PATTERN/'
# Use prefix/suffix to improve resulting file names
csplit -f 'prefix-' -b '%d.extension' input.file '/PATTERN/' '{*}'

@ -1,22 +0,0 @@
# Manage printers through CUPS:
http://localhost:631 (in web browser)
# Print file from command line
lp myfile.txt
# Display print queue
lpq
# Remove print job from queue
lprm 545
or
lprm -
# Print log location
/var/log/cups
# Reject new jobs
cupsreject printername
# Accept new jobs
cupsaccept printername

@ -1,41 +0,0 @@
# Download a single file
curl http://path.to.the/file
# Download a file and specify a new filename
curl http://example.com/file.zip -o new_file.zip
# Download multiple files
curl -O URLOfFirstFile -O URLOfSecondFile
# Download all sequentially numbered files (1-24)
curl http://example.com/pic[1-24].jpg
# Download a file and pass HTTP Authentication
curl -u username:password URL
# Download a file with a Proxy
curl -x proxysever.server.com:PORT http://addressiwantto.access
# Download a file from FTP
curl -u username:password -O ftp://example.com/pub/file.zip
# Get an FTP directory listing
curl ftp://username:password@example.com
# Resume a previously failed download
curl -C - -o partial_file.zip http://example.com/file.zip
# Fetch only the HTTP headers from a response
curl -I http://example.com
# Fetch your external IP and network info as JSON
curl http://ifconfig.me/all/json
# Limit the rate of a download
curl --limit-rate 1000B -O http://path.to.the/file
# Get your global IP
curl httpbin.org/ip
# Get only the HTTP status code
curl -o /dev/null -w '%{http_code}\n' -s -I URL

@ -1,2 +0,0 @@
# To cut out the third field of text or stdoutput that is delimited by a #:
cut -d# -f3

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

@ -1,22 +0,0 @@
# Read from {/dev/urandom} 2*512 Bytes and put it into {/tmp/test.txt}
# Note: At the first iteration, we read 512 Bytes.
# Note: At the second iteration, we read 512 Bytes.
dd if=/dev/urandom of=/tmp/test.txt count=2 bs=512
# Watch the progress of 'dd'
dd if=/dev/zero of=/dev/null bs=4KB &; export dd_pid=`pgrep '^dd'`; while [[ -d /proc/$dd_pid ]]; do kill -USR1 $dd_pid && sleep 1 && clear; done
# Watch the progress of 'dd' with `pv` and `dialog` (apt-get install pv dialog)
(pv -n /dev/zero | dd of=/dev/null bs=128M conv=notrunc,noerror) 2>&1 | dialog --gauge "Running dd command (cloning), please wait..." 10 70 0
# Watch the progress of 'dd' with `pv` and `zenity` (apt-get install pv zenity)
(pv -n /dev/zero | dd of=/dev/null bs=128M conv=notrunc,noerror) 2>&1 | zenity --title 'Running dd command (cloning), please wait...' --progress
# Watch the progress of 'dd' with the built-in `progress` functionality (introduced in coreutils v8.24)
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

@ -1,7 +0,0 @@
# Extract contents of a .deb file
$ ar vx foo.deb # -> data.tar.gz
$ tar xf data.tar.gz
# Install .deb file to a debian like system, e.g. ubuntu
$ sudo dpkg -i foo.deb
$ sudo apt-get install -f

@ -1,2 +0,0 @@
# Printout disk free space in a human readable format
df -h

@ -1,10 +0,0 @@
# To release the current IP address:
sudo dhclient -r
# To obtain a new IP address:
sudo dhclient
# Running the above in sequence is a common way of refreshing an IP.
# To obtain a new IP address for a specific interface:
sudo dhclient eth0

@ -1,26 +0,0 @@
# To view the differences between two files:
diff -u version1 version2
# To view the differences between two directories:
diff -ur folder1/ folder2/
# To ignore the white spaces:
diff -ub version1 version2
# To ignore the blank lines:
diff -uB version1 version2
# To ignore the differences between uppercase and lowercase:
diff -ui version1 version2
# To report whether the files differ:
diff -q version1 version2
# To report whether the files are identical:
diff -s version1 version2
# To diff the output of two commands or scripts:
diff <(command1) <(command2)
# Generate a patch file from two files
diff -Naur version1 version2 > version.patch

@ -1,29 +0,0 @@
# INSTALL
# ==============================================================================
# Edit /etc/default/distcc and set theses vars
# STARTDISTCC="true"
# ALLOWEDNETS="127.0.0.1 192.168.1.0/24"# Your computer and local computers
# #LISTENER="127.0.0.1"# Comment it
# ZEROCONF="true"# Auto configuration
# REMEMBER 1:
# Start/Restart your distccd servers before using one of these commands.
# service distccd start
# REMEMBER 2:
# Do not forget to install on each machine DISTCC.
# No need to install libs ! Only main host need libs !
# USAGE
# ==============================================================================
# Run make with 4 thread (a cross network) in auto configuration.
# Note: for gcc, Replace CXX by CC and g++ by gcc
ZEROCONF='+zeroconf' make -j4 CXX='distcc g++'
# Run make with 4 thread (a cross network) in static configuration (2 ip)
# Note: for gcc, Replace CXX by CC and g++ by gcc
DISTCC_HOSTS='127.0.0.1 192.168.1.69' make -j4 CXX='distcc g++'
# Show hosts aviables
ZEROCONF='+zeroconf' distcc --show-hosts

@ -1,16 +0,0 @@
# To install the latest version of a package:
dnf install <package name>
# To search package details for the given string
dnf search <string>
# To find which package provides a binary
dnf provides <path to binary>
# The following are available after installing "dnf-plugins-core"
# Download a package
dnf download <package name>
# install the build dependencies for a SRPM or from a .spec file
dnf builddep <srpm/.spec file>

@ -1,32 +0,0 @@
# Start docker daemon
docker -d
# start a container with an interactive shell
docker run -ti <image_name> /bin/bash
# "shell" into a running container (docker-1.3+)
docker exec -ti <container_name> bash
# inspect a running container
docker inspect <container_name> (or <container_id>)
# Get the process ID for a container
# Source: https://github.com/jpetazzo/nsenter
docker inspect --format {{.State.Pid}} <container_name_or_ID>
# List the current mounted volumes for a container (and pretty print)
# Source:
# http://nathanleclaire.com/blog/2014/07/12/10-docker-tips-and-tricks-that-will-make-you-sing-a-whale-song-of-joy/
docker inspect --format='{{json .Volumes}}' <container_id> | python -mjson.tool
# Copy files/folders between a container and your host
docker cp foo.txt mycontainer:/foo.txt
# list currently running containers
docker ps
# list all containers
docker ps -a
# list all images
docker images

@ -1,11 +0,0 @@
# Install the package or upgrade it
dpkg -i test.deb
# Remove a package including configuration files
dpkg -P test.deb
# List all installed packages with versions and details
dpkg -I
# Find out if a Debian package is installed or not
dpkg -s test.deb | grep Status

@ -1,5 +0,0 @@
# To sort directories/files by size
du -sk *| sort -rn
# To show cumulative humanreadable size
du -sh

@ -1,64 +0,0 @@
# Running emacs
GUI mode $ emacs
Terminal mode $ emacs -nw
# Basic usage
Indent Select text then press TAB
Cut CTRL-w
Copy ALT-w
Paste ("yank") CTRL-y
Begin selection CTRL-SPACE
Search/Find CTRL-s
Replace ALT-% (ALT-SHIFT-5)
Save CTRL-x CTRL-s
Save as CTRL-x CTRL-w
Load/Open CTRL-x CTRL-f
Undo CTRL-x u
Highlight all text CTRL-x h
Directory listing CTRL-x d
Cancel a command CTRL-g
Font size bigger CTRL-x CTRL-+
Font size smaller CTRL-x CTRL--
# Buffers
Split screen vertically CTRL-x 2
Split screen vertically with 5 row height CTRL-u 5 CTRL-x 2
Split screen horizontally CTRL-x 3
Split screen horizontally with 24 column width CTRL-u 24 CTRL-x 3
Revert to single screen CTRL-x 1
Hide the current screen CTRL-x 0
Move to the next screen CTRL-x o
Kill the current buffer CTRL-x k
Select a buffer CTRL-x b
Run command in the scratch buffer CTRL-x CTRL-e
# Navigation ( backward / forward )
Character-wise CTRL-b , CTRL-f
Word-wise ALT-b , ALT-f
Line-wise CTRL-p , CTRL-n
Sentence-wise ALT-a , ALT-e
Paragraph-wise ALT-{ , ALT-}
Function-wise CTRL-ALT-a , CTRL-ALT-e
Line beginning / end CTRL-a , CTRL-e
# Other stuff
Open a shell ALT-x eshell
Goto a line number ALT-x goto-line
Word wrap ALT-x toggle-word-wrap
Spell checking ALT-x flyspell-mode
Line numbers ALT-x linum-mode
Toggle line wrap ALT-x visual-line-mode
Compile some code ALT-x compile
List packages ALT-x package-list-packages
# Line numbers
To add line numbers and enable moving to a line with CTRL-l:
(global-set-key "\C-l" 'goto-line)
(add-hook 'find-file-hook (lambda () (linum-mode 1)))

@ -1,5 +0,0 @@
# Calling export with no arguments will show current shell attributes
export
# Create new environment variable
export VARNAME="value"

@ -1,23 +0,0 @@
# Print file metadata etc.
ffmpeg -i path/to/file.ext
# Convert all m4a files to mp3
for f in *.m4a; do ffmpeg -i "$f" -acodec libmp3lame -vn -b:a 320k "${f%.m4a}.mp3"; done
# Convert video from .foo to .bar
# -g : GOP, for searchability
ffmpeg -i input.foo -vcodec bar -acodec baz -b:v 21000k -b:a 320k -g 150 -threads 4 output.bar
# Convert image sequence to video
ffmpeg -r 18 -pattern_type glob -i '*.png' -b:v 21000k -s hd1080 -vcodec vp9 -an -pix_fmt yuv420p -deinterlace output.ext
# Combine video and audio into one file
ffmpeg -i video.ext -i audio.ext -c:v copy -c:a copy output.ext
# Listen to 10 seconds of audio from a video file
#
# -ss : start time
# -t : seconds to cut
# -autoexit : closes ffplay as soon as the audio finishes
ffmpeg -ss 00:34:24.85 -t 10 -i path/to/file.mp4 -f mp3 pipe:play | ffplay -i pipe:play -autoexit

@ -1,47 +0,0 @@
# To find files by case-insensitive extension (ex: .jpg, .JPG, .jpG):
find . -iname "*.jpg"
# To find directories:
find . -type d
# To find files:
find . -type f
# To find files by octal permission:
find . -type f -perm 777
# To find files with setuid bit set:
find . -xdev \( -perm -4000 \) -type f -print0 | xargs -0 ls -l
# To find files with extension '.txt' and remove them:
find ./path/ -name '*.txt' -exec rm '{}' \;
# To find files with extension '.txt' and look for a string into them:
find ./path/ -name '*.txt' | xargs grep 'string'
# To find files with size bigger than 5 Mebibyte and sort them by size:
find . -size +5M -type f -print0 | xargs -0 ls -Ssh | sort -z
# To find files bigger than 2 Megabyte and list them:
find . -type f -size +200000000c -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
# To find files modified more than 7 days ago and list file information
find . -type f -mtime +7d -ls
# To find symlinks owned by a user and list file information
find . -type l --user=username -ls
# To search for and delete empty directories
find . -type d -empty -exec rmdir {} \;
# To search for directories named build at a max depth of 2 directories
find . -maxdepth 2 -name build -type d
# To search all files who are not in .git directory
find . ! -iwholename '*.git*' -type f
# 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 {} \;

@ -1,35 +0,0 @@
# basic loop
for i in 1 2 3 4 5 6 7 8 9 10
do
echo $i
done
# loop ls command results
for var in `ls -alF`
do
echo $var
done
# loop over all the JPG files in the current directory
for jpg_file in *.jpg
do
echo $jpg_file
done
# loop specified number of times
for i in `seq 1 10`
do
echo $i
done
# loop specified number of times: the C/C++ style
for ((i=1;i<=10;++i))
do
echo $i
done
# loop specified number of times: the brace expansion
for i in {1..10}
do
echo $i
done

@ -1,21 +0,0 @@
# Compile a file
gcc file.c
# Compile a file with a custom output
gcc -o file file.c
# Debug symbols
gcc -g
# Debug with all symbols.
gcc -ggdb3
# Build for 64 bytes
gcc -m64
# Include the directory {/usr/include/myPersonnal/lib/} to the list of path for #include <....>
# With this option, no warning / error will be reported for the files in {/usr/include/myPersonnal/lib/}
gcc -isystem /usr/include/myPersonnal/lib/
# Build a GUI for windows (Mingw) (Will disable the term/console)
gcc -mwindows

@ -1,26 +0,0 @@
# start the debugger
gdb your-executable
# set a breakpoint
b some-method, break some-method
# run the program
r, run
# when a breakpoint was reached:
# run the current line, stepping over any invocations
n, next
# run the current line, stepping into any invocations
s, step
# print a stacktrace
bt, backtrace
# evaluate an expression and print the result
p length=strlen(string)
# list surrounding source code
l, list
# continue execution
c, continue
# exit gdb (after program terminated)
q, quit

@ -1,151 +0,0 @@
# To set your identity:
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
# To set your editor:
git config --global core.editor emacs
# To enable color:
git config --global color.ui true
# To stage all changes for commit:
git add --all
# To stash changes locally, this will keep the changes in a separate changelist
# called stash and the working directory is cleaned. You can apply changes
# from the stash anytime
git stash
# To stash changes with a message
git stash save "message"
# To list all the stashed changes
git stash list
# To apply the most recent change and remove the stash from the stash list
git stash pop
# To apply any stash from the list of stashes. This does not remove the stash
# from the stash list
git stash apply stash@{6}
# To commit staged changes
git commit -m "Your commit message"
# To edit previous commit message
git commit --amend
# Git commit in the past
git commit --date="`date --date='2 day ago'`"
git commit --date="Jun 13 18:30:25 IST 2015"
# more recent versions of Git also support --date="2 days ago" directly
# To change the date of an existing commit
git filter-branch --env-filter \
'if [ $GIT_COMMIT = 119f9ecf58069b265ab22f1f97d2b648faf932e0 ]
then
export GIT_AUTHOR_DATE="Fri Jan 2 21:38:53 2009 -0800"
export GIT_COMMITTER_DATE="Sat May 19 01:01:01 2007 -0700"
fi'
# To removed staged and working directory changes
git reset --hard
# To go 2 commits back
git reset --hard HEAD~2
# To remove untracked files
git clean -f -d
# To remove untracked and ignored files
git clean -f -d -x
# To push to the tracked master branch:
git push origin master
# To push to a specified repository:
git push git@github.com:username/project.git
# To delete the branch "branch_name"
git branch -D branch_name
# To make an exisiting branch track a remote branch
git branch -u upstream/foo
# To see who commited which line in a file
git blame filename
# To sync a fork with the master repo:
git remote add upstream git@github.com:name/repo.git # Set a new repo
git remote -v # Confirm new remote repo
git fetch upstream # Get branches
git branch -va # List local - remote branches
git checkout master # Checkout local master branch
git checkout -b new_branch # Create and checkout a new branch
git merge upstream/master # Merge remote into local repo
git show 83fb499 # Show what a commit did.
git show 83fb499:path/fo/file.ext # Shows the file as it appeared at 83fb499.
git diff branch_1 branch_2 # Check difference between branches
git log # Show all the commits
git status # Show the changes from last commit
# Commit history of a set of files
git log --pretty=email --patch-with-stat --reverse --full-index -- Admin\*.py > Sripts.patch
# Import commits from another repo
git --git-dir=../some_other_repo/.git format-patch -k -1 --stdout <commit SHA> | git am -3 -k
# View commits that will be pushed
git log @{u}..
# View changes that are new on a feature branch
git log -p feature --not master
git diff master...feature
# Interactive rebase for the last 7 commits
git rebase -i @~7
# Diff files WITHOUT considering them a part of git
# This can be used to diff files that are not in a git repo!
git diff --no-index path/to/file/A path/to/file/B
# To pull changes while overwriting any local commits
git fetch --all
git reset --hard origin/master
# Update all your submodules
git submodule update --init --recursive
# Perform a shallow clone to only get latest commits
# (helps save data when cloning large repos)
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
# Revert a commit and keep the history of the reverted change as a separate revert commit
git revert <commit SHA>
# Pich a commit from a branch to current branch. This is different than merge as
# this just applies a single commit from a branch to current branch
git cherry-pick <commit SHA1>

@ -1,173 +0,0 @@
# Create a key
gpg --gen-key
# Show keys
To list a summary of all keys
gpg --list-keys
To show your public key
gpg --armor --export
To show the fingerprint for a key
gpg --fingerprint KEY_ID
# Search for keys
gpg --search-keys 'user@emailaddress.com'
# To Encrypt a File
gpg --encrypt --recipient 'user@emailaddress.com' example.txt
# To Decrypt a File
gpg --output example.txt --decrypt example.txt.gpg
# Export keys
gpg --output ~/public_key.txt --armor --export KEY_ID
gpg --output ~/private_key.txt --armor --export-secret-key KEY_ID
Where KEY_ID is the 8 character GPG key ID.
Store these files to a safe location, such as a USB drive, then
remove the private key file.
shred -zu ~/private_key.txt
# Import keys
Retrieve the key files which you previously exported.
gpg --import ~/public_key.txt
gpg --allow-secret-key-import --import ~/private_key.txt
Then delete the private key file.
shred -zu ~/private_key.txt
# Revoke a key
Create a revocation certificate.
gpg --output ~/revoke.asc --gen-revoke KEY_ID
Where KEY_ID is the 8 character GPG key ID.
After creating the certificate import it.
gpg --import ~/revoke.asc
Then ensure that key servers know about the revokation.
gpg --send-keys KEY_ID
# Signing and Verifying files
If you're uploading files to launchpad you may also want to include
a GPG signature file.
gpg -ba filename
or if you need to specify a particular key:
gpg --default-key <key ID> -ba filename
This then produces a file with a .asc extension which can be uploaded.
If you need to set the default key more permanently then edit the
file ~/.gnupg/gpg.conf and set the default-key parameter.
To verify a downloaded file using its signature file.
gpg --verify filename.asc
# Signing Public Keys
Import the public key or retrieve it from a server.
gpg --keyserver <keyserver> --recv-keys <Key_ID>
Check its fingerprint against any previously stated value.
gpg --fingerprint <Key_ID>
Sign the key.
gpg --sign-key <Key_ID>
Upload the signed key to a server.
gpg --keyserver <keyserver> --send-key <Key_ID>
# Change the email address associated with a GPG key
gpg --edit-key <key ID>
adduid
Enter the new name and email address. You can then list the addresses with:
list
If you want to delete a previous email address first select it:
uid <list number>
Then delete it with:
deluid
To finish type:
save
Publish the key to a server:
gpg --send-keys <key ID>
# Creating Subkeys
Subkeys can be useful if you don't wish to have your main GPG key
installed on multiple machines. In this way you can keep your
master key safe and have subkeys with expiry periods or which may be
separately revoked installed on various machines. This avoids
generating entirely separate keys and so breaking any web of trust
which has been established.
gpg --edit-key <key ID>
At the prompt type:
addkey
Choose RSA (sign only), 4096 bits and select an expiry period.
Entropy will be gathered.
At the prompt type:
save
You can also repeat the procedure, but selecting RSA (encrypt only).
To remove the master key, leaving only the subkey/s in place:
gpg --export-secret-subkeys <subkey ID> > subkeys
gpg --export <key ID> > pubkeys
gpg --delete-secret-key <key ID>
Import the keys back.
gpg --import pubkeys subkeys
Verify the import.
gpg -K
Should show sec# instead of just sec.

@ -1,29 +0,0 @@
# Search a file for a pattern
grep pattern file
# Case insensitive search (with line numbers)
grep -in pattern file
# Recursively grep for string <pattern> in folder:
grep -R pattern folder
# Read search patterns from a file (one per line)
grep -f pattern_file file
# Find lines NOT containing pattern
grep -v pattern file
# You can grep with regular expressions
grep "^00" file #Match lines starting with 00
grep -E "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" file #Find IP add
# Find all files which match {pattern} in {directory}
# This will show: "file:line my research"
grep -rnw 'directory' -e "pattern"
# Exclude grep from your grepped output of ps.
# Add [] to the first letter. Ex: sshd -> [s]shd
ps aux | grep '[h]ttpd'
# Colour in red {bash} and keep all other lines
ps aux | grep -E --color 'bash|$'

@ -1,3 +0,0 @@
# To reduce the size of a pdf file:
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf

@ -1,12 +0,0 @@
# To estimate the number and the size of all mails on youremail@gmail.com
gyb --email youremail@gmail.com --action estimate
# To backup from youremail@gmail.com to your local-folder
gyb --email youremail@gmail.com --action backup --local-folder "~/MyLocalFolder/"
# To backup from youremail@gmail.com only important or starred emails to the
# default local folder GYB-GMail-Backup-youremail@gmail.com
gyb --email youremail@gmail.com --search "is:important OR is:starred"
# To restore from your local-folder to youremail@gmail.com
gyb --email youremail@gmail.com --action restore --local-folder "~/MyLocalFolder/"

@ -1,17 +0,0 @@
# To create a *.gz compressed file
gzip test.txt
# To create a *.gz compressed file to a specific location using -c option (standard out)
gzip -c test.txt > test_custom.txt.gz
# To uncompress a *.gz file
gzip -d test.txt.gz
# Display compression ratio of the compressed file using gzip -l
gzip -l *.gz
# Recursively compress all the files under a specified directory
gzip -r documents_directory
# To create a *.gz compressed file and keep the original
gzip < test.txt > test.txt.gz

@ -1,32 +0,0 @@
# Display all hardware details
sudo lshw
# List currently loaded kernel modules
lsmod
# List all modules available to the system
find /lib/modules/$(uname -r) -type f -iname "*.ko"
# Load a module into kernel
modprobe modulename
# Remove a module from kernel
modprobe -r modulename
# List devices connected via pci bus
lspci
# Debug output for pci devices (hex)
lspci -vvxxx
# Display cpu hardware stats
cat /proc/cpuinfo
# Display memory hardware stats
cat /proc/meminfo
# Output the kernel ring buffer
dmesg
# Ouput kernel messages
dmesg --kernel

@ -1,8 +0,0 @@
# To show the first 10 lines of file
head file
# To show the first N lines of file
head -n N file
# To show the first N bytes of file
head -c N file

@ -1,20 +0,0 @@
# Clone a directory
hg clone
# Add files to hg tracker
hg add filename
# Add all files in a folder to hg tracker
hg add folder/
# Create a commit with all tracked changes and a message
hg commit -m "message"
# Push commits to source repository
hg push
# Pull changes from source repository
hg pull
# Rebase local commits to disambiguate with remote repository
hg pull --rebase

@ -1,3 +0,0 @@
# To see most used top 10 commands:
history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10

@ -1,195 +0,0 @@
# Custom HTTP method HTTP headers and JSON data:
http PUT example.org X-API-Token:123 name=John
# Submitting forms:
http -f POST example.org hello=World
# See the request that is being sent using one of the output options:
http -v example.org
# Use Github API to post a comment on an issue with authentication:
http -a USERNAME POST https://api.github.com/repos/jkbrzt/httpie/issues/83/comments body='HTTPie is awesome!'
# Upload a file using redirected input:
http example.org < file.json
# Download a file and save it via redirected output:
http example.org/file > file
# Download a file wget style:
http --download example.org/file
# Use named sessions_ to make certain aspects or the communication
# persistent between requests to the same host:
# http --session=logged-in -a username:password httpbin.org/get API-Key:123
http --session=logged-in httpbin.org/headers
# Set a custom Host header to work around missing DNS records:
http localhost:8000 Host:example.com
# Simple JSON example:
http PUT example.org name=John email=john@example.org
# Non-string fields use the := separator, which allows you to embed raw
# JSON into the resulting object. Text and raw JSON files can also be
# embedded into fields using =@ and :=@:
http PUT api.example.com/person/1 name=John age:=29 married:=false hobbies:='["http", "pies"]' description=@about-john.txt bookmarks:=@bookmarks.json
# Send JSON data stored in a file:
http POST api.example.com/person/1 < person.json
# Regular Forms
http --form POST api.example.org/person/1 name='John Smith' email=john@example.org cv=@~/Documents/cv.txt
# File Upload Forms
# If one or more file fields is present, the serialization and content
# type is multipart/form-data:
http -f POST example.com/jobs name='John Smith' cv@~/Documents/cv.pdf
# To set custom headers you can use the Header:Value notation:
http example.org User-Agent:Bacon/1.0 'Cookie:valued-visitor=yes;foo=bar' X-Foo:Bar Referer:http://httpie.org/
# Basic auth:
http -a username:password example.org
# Digest auth:
http --auth-type=digest -a username:password example.org
# With password prompt:
http -a username example.org
# Authorization information from your ~/.netrc file is honored as well:
cat ~/.netrc
machine httpbin.org
login httpie
# password test
http httpbin.org/basic-auth/httpie/test
# You can specify proxies to be used through the --proxy argument for each
# protocol (which is included in the value in case of redirects across
# protocols):
http --proxy=http:http://10.10.1.10:3128 --proxy=https:https://10.10.1.10:1080 example.org
# With Basic authentication:
http --proxy=http:http://user:pass@10.10.1.10:3128 example.org
# To skip the HOST'S SSL CERTIFICATE VERIFICATION, you can pass
# --verify=no (default is yes):
http --verify=no https://example.org
# You can also use --verify=<CA_BUNDLE_PATH> to set a CUSTOM CA BUNDLE path:
http --verify=/ssl/custom_ca_bundle https://example.org
# To use a CLIENT SIDE CERTIFICATE for the SSL communication, you can pass
# the path of the cert file with --cert:
http --cert=client.pem https://example.org
# If the PRIVATE KEY is not contained in the cert file you may pass the
# path of the key file with --cert-key:
http --cert=client.crt --cert-key=client.key https://example.org
# You can control what should be printed via several options:
# --headers, -h Only the response headers are printed.
# --body, -b Only the response body is printed.
# --verbose, -v Print the whole HTTP exchange (request and response).
# --print, -p Selects parts of the HTTP exchange.
http --verbose PUT httpbin.org/put hello=world
# Print request and response headers:
# Character Stands for
# ----------- -------------------
# H Request headers.
# B Request body.
# h Response headers.
# b Response body.
http --print=Hh PUT httpbin.org/put hello=world
# Let's say that there is an API that returns the whole resource when it
# is updated, but you are only interested in the response headers to see
# the status code after an update:
http --headers PATCH example.org/Really-Huge-Resource name='New Name'
# Redirect from a file:
http PUT example.com/person/1 X-API-Token:123 < person.json
# Or the output of another program:
grep '401 Unauthorized' /var/log/httpd/error_log | http POST example.org/intruders
# You can use echo for simple data:
echo '{"name": "John"}' | http PATCH example.com/person/1 X-API-Token:123
# You can even pipe web services together using HTTPie:
http GET https://api.github.com/repos/jkbrzt/httpie | http POST httpbin.org/post
# You can use cat to enter multiline data on the terminal:
cat | http POST example.com
<paste>
# ^D
cat | http POST example.com/todos Content-Type:text/plain
- buy milk
- call parents
^D
# On OS X, you can send the contents of the clipboard with pbpaste:
pbpaste | http PUT example.com
# Passing data through stdin cannot be combined with data fields specified
# on the command line:
echo 'data' | http POST example.org more=data # This is invalid
# AN ALTERNATIVE TO REDIRECTED stdin is specifying a filename (as
# @/path/to/file) whose content is used as if it came from stdin.
# It has the advantage that THE Content-Type HEADER IS AUTOMATICALLY SET
# to the appropriate value based on the filename extension. For example,
# the following request sends the verbatim contents of that XML file with
# Content-Type: application/xml:
http PUT httpbin.org/put @/data/file.xml
# Download a file:
http example.org/Movie.mov > Movie.mov
# Download an image of Octocat, resize it using ImageMagick, upload it
# elsewhere:
http octodex.github.com/images/original.jpg | convert - -resize 25% - | http example.org/Octocats
# Force colorizing and formatting, and show both the request and the
# response in less pager:
http --pretty=all --verbose example.org | less -R
# When enabled using the --download, -d flag, response headers are printed
# to the terminal (stderr), and a progress bar is shown while the response
# body is being saved to a file.
http --download https://github.com/jkbrzt/httpie/tarball/master
# You can also redirect the response body to another program while the
# response headers and progress are still shown in the terminal:
http -d https://github.com/jkbrzt/httpie/tarball/master | tar zxf -
# If --output, -o is specified, you can resume a partial download using
# the --continue, -c option. This only works with servers that support
# Range requests and 206 Partial Content responses. If the server doesn't
# support that, the whole file will simply be downloaded:
http -dco file.zip example.org/file
# Prettified streamed response:
http --stream -f -a YOUR-TWITTER-NAME https://stream.twitter.com/1/statuses/filter.json track='Justin Bieber'
# Send each new tweet (JSON object) mentioning "Apple" to another
# server as soon as it arrives from the Twitter streaming API:
http --stream -f -a YOUR-TWITTER-NAME https://stream.twitter.com/1/statuses/filter.json track=Apple | while read tweet; do echo "$tweet" | http POST example.org/tweets ; done
# Create a new session named user1 for example.org:
http --session=user1 -a user1:password example.org X-Foo:Bar
# Now you can refer to the session by its name, and the previously used
# authorization and HTTP headers will automatically be set:
http --session=user1 example.org
# To create or reuse a different session, simple specify a different name:
http --session=user2 -a user2:password example.org X-Bar:Foo
# Instead of a name, you can also directly specify a path to a session
# file. This allows for sessions to be re-used across multiple hosts:
http --session=/tmp/session.json example.orghttp --session=/tmp/session.json admin.example.orghttp --session=~/.httpie/sessions/another.example.org/test.json example.orghttp --session-read-only=/tmp/session.json example.org

@ -1,74 +0,0 @@
As a contributor to open-source
-------------------------------
# clone your own project
$ git clone dotfiles
→ git clone git://github.com/YOUR_USER/dotfiles.git
# clone another project
$ git clone github/hub
→ git clone git://github.com/github/hub.git
# see the current project's issues
$ git browse -- issues
→ open https://github.com/github/hub/issues
# open another project's wiki
$ git browse mojombo/jekyll wiki
→ open https://github.com/mojombo/jekyll/wiki
## Example workflow for contributing to a project:
$ git clone github/hub
$ cd hub
# create a topic branch
$ git checkout -b feature
→ ( making changes ... )
$ git commit -m "done with feature"
# It's time to fork the repo!
$ git fork
→ (forking repo on GitHub...)
→ git remote add YOUR_USER git://github.com/YOUR_USER/hub.git
# push the changes to your new remote
$ git push YOUR_USER feature
# open a pull request for the topic branch you've just pushed
$ git pull-request
→ (opens a text editor for your pull request message)
As an open-source maintainer
----------------------------
# fetch from multiple trusted forks, even if they don't yet exist as remotes
$ git fetch mislav,cehoffman
→ git remote add mislav git://github.com/mislav/hub.git
→ git remote add cehoffman git://github.com/cehoffman/hub.git
→ git fetch --multiple mislav cehoffman
# check out a pull request for review
$ git checkout https://github.com/github/hub/pull/134
→ (creates a new branch with the contents of the pull request)
# directly apply all commits from a pull request to the current branch
$ git am -3 https://github.com/github/hub/pull/134
# cherry-pick a GitHub URL
$ git cherry-pick https://github.com/xoebus/hub/commit/177eeb8
→ git remote add xoebus git://github.com/xoebus/hub.git
→ git fetch xoebus
→ git cherry-pick 177eeb8
# `am` can be better than cherry-pick since it doesn't create a remote
$ git am https://github.com/xoebus/hub/commit/177eeb8
# open the GitHub compare view between two releases
$ git compare v0.9..v1.0
# put compare URL for a topic branch to clipboard
$ git compare -u feature | pbcopy
# create a repo for a new project
$ git init
$ git add . && git commit -m "It begins."
$ git create -d "My new thing"
→ (creates a new project on GitHub with the name of current directory)
$ git push origin master

@ -1,3 +0,0 @@
# To convert file (iconv.src) from iso-8859-1 to utf-8 and save to
# /tmp/iconv.out
iconv -f iso-8859-1 -t utf-8 iconv.src -o /tmp/iconv.out

@ -1,14 +0,0 @@
# Display network settings of the first ethernet adapter
ifconfig wlan0
# Display all interfaces, even if down
ifconfig -a
# Take down / up the wireless adapter
ifconfig wlan0 {up|down}
# Set a static IP and netmask
ifconfig eth0 192.168.1.100 netmask 255.255.255.0
# You may also need to add a gateway IP
route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1

@ -1,2 +0,0 @@
# format C/C++ source according to the style of Kernighan and Ritchie (K&R), no tabs, 3 spaces per indent, wrap lines at 120 characters.
indent -i3 -kr -nut -l120

@ -1,32 +0,0 @@
# Display all interfaces with addresses
ip addr
# Take down / up the wireless adapter
ip link set dev wlan0 {up|down}
# Set a static IP and netmask
ip addr add 192.168.1.100/32 dev eth0
# Remove a IP from an interface
ip addr del 192.168.1.100/32 dev eth0
# Remove all IPs from an interface
ip address flush dev eth0
# Display all routes
ip route
# Display all routes for IPv6
ip -6 route
# Add default route via gateway IP
ip route add default via 192.168.1.1
# Add route via interface
ip route add 192.168.0.0/24 dev eth0
# Change your mac address
ip link set dev eth0 address aa:bb:cc:dd:ee:ff
# View neighbors (using ARP and NDP)
ip neighbor show

@ -1,40 +0,0 @@
# Show hit for rules with auto refresh
watch --interval 0 'iptables -nvL | grep -v "0 0"'
# Show hit for rule with auto refresh and highlight any changes since the last refresh
watch -d -n 2 iptables -nvL
# Block the port 902 and we hide this port from nmap.
iptables -A INPUT -i eth0 -p tcp --dport 902 -j REJECT --reject-with icmp-port-unreachable
# Note, --reject-with accept:
# icmp-net-unreachable
# icmp-host-unreachable
# icmp-port-unreachable <- Hide a port to nmap
# icmp-proto-unreachable
# icmp-net-prohibited
# icmp-host-prohibited or
# icmp-admin-prohibited
# tcp-reset
# Add a comment to a rule:
iptables ... -m comment --comment "This rule is here for this reason"
# To remove or insert a rule:
# 1) Show all rules
iptables -L INPUT --line-numbers
# OR iptables -nL --line-numbers
# Chain INPUT (policy ACCEPT)
# num target prot opt source destination
# 1 ACCEPT udp -- anywhere anywhere udp dpt:domain
# 2 ACCEPT tcp -- anywhere anywhere tcp dpt:domain
# 3 ACCEPT udp -- anywhere anywhere udp dpt:bootps
# 4 ACCEPT tcp -- anywhere anywhere tcp dpt:bootps
# 2.a) REMOVE (-D) a rule. (here an INPUT rule)
iptables -D INPUT 2
# 2.b) OR INSERT a rule.
iptables -I INPUT {LINE_NUMBER} -i eth1 -p tcp --dport 21 -s 123.123.123.123 -j ACCEPT -m comment --comment "This rule is here for this reason"

@ -1,33 +0,0 @@
# To connect to an IRC server
/connect <server domain name>
# To join a channel
/join #<channel name>
# To set a nickname
/nick <my nickname>
# To send a private message to a user
/msg <nickname>
# To close the current channel window
/wc
# To switch between channel windows
ALT+<number>, eg. ALT+1, ALT+2
# To list the nicknames within the active channel
/names
# To change the channel topic
/topic <description>
# 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

@ -1,8 +0,0 @@
# Display wireless settings of the first wireless adapter
iwconfig wlan0
# Take down / up the wireless adapter
iwconfig wlan0 txpower {on|auto|off}
# Change the mode of the wireless adapter
iwconfig wlan0 mode {managed|ad-hoc|monitor}

@ -1,32 +0,0 @@
# Actively follow log (like tail -f)
journalctl -f
# Display all errors since last boot
journalctl -b -p err
# Filter by time period
journalctl --since=2012-10-15 --until="2011-10-16 23:59:59"
# Show list of systemd units logged in journal
journalctl -F _SYSTEMD_UNIT
# Filter by specific unit
journalctl -u dbus
# Filter by executable name
journalctl /usr/bin/dbus-daemon
# Filter by PID
journalctl _PID=123
# Filter by Command, e.g., sshd
journalctl _COMM=sshd
# Filter by Command and time period
journalctl _COMM=crond --since '10:00' --until '11:00'
# List all available boots
journalctl --list-boots
# Filter by specific User ID e.g., user id 1000
journalctl _UID=1000

@ -1,13 +0,0 @@
# Pretty print the json
jq "." < filename.json
# Access the value at key "foo"
jq '.foo'
# Access first list item
jq '.[0]'
# Slice & Dice
jq '.[2:4]'
jq '.[:3]'
jq '.[-2:]'

@ -1,25 +0,0 @@
# Add entry to default jrnl (from your configured text editor)
jrnl
# Add entry to default jrnl
jrnl Write entry here.
# List of tags
jrnl --tags
# Entries per tag
jrnl @tag
# Export jrnl as json
jrnl --export json
# Entries in a timeframe
jrnl -from 2009 -until may
# Add Sublime text to .jrnl_config
# Windows
"editor": "F:\\Powerpack\\Sublime\\sublime_text.exe -w"
# Linux
"editor": "/usr/bin/sublime -w"

@ -1,5 +0,0 @@
# Kill a process gracefully
kill -15 <process id>
# Kill a process forcefully
kill -9 <process id>

@ -1,9 +0,0 @@
# 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.

@ -1,23 +0,0 @@
# Display available libraries
ldconfig -p
# Update library resources
ldconfig
# Display libraries and file location
ldd
# Libraries available to apps in real-time
"Dynamic Libraries" (.so.)
# Libraries only available to apps when installed (imported)
"Static Libraries" (.a.)
# Standard (usual) library file location
/lib
# Sofware-accessible source for library info
/etc/ld.so.cache # (binary)
# Human-readable source for library info
/etc/ld.so.conf # (points to /etc/ld.so.conf.d)

@ -1,5 +0,0 @@
# To create a symlink:
ln -s path/to/the/target/directory name-of-symlink
# Symlink, while overwriting existing destination files
ln -sf /some/dir/exec /usr/bin/exec

@ -1,17 +0,0 @@
# Displays everything in the target directory
ls path/to/the/target/directory
# Displays everything including hidden files
ls -a
# Displays all files, along with the size (with unit suffixes) and timestamp
ls -lh
# Display files, sorted by size
ls -S
# Display directories only
ls -d */
# Display directories only, include hidden
ls -d .*/ */

Some files were not shown because too many files have changed in this diff Show More