From b98364d7778912935422cd48337329d98e32fc47 Mon Sep 17 00:00:00 2001 From: remisa Date: Thu, 21 May 2020 22:29:13 +0430 Subject: [PATCH 1/2] Abstraction added --- .gitignore | 2 +- .vscode/launch.json | 11 +- .vscode/settings.json | 1 + .vscode/tasks.json | 12 + .vscodeignore | 9 +- COMMANDS.md | 2340 ++++++------- build.js | 116 + docgen.js | 47 - nsroot/README.md | 4 + nsroot/archive/compress-tar-gz.json | 5 + nsroot/archive/decompress-tar-gz.json | 5 + nsroot/array/all-elements.json | 5 + nsroot/array/at-index.json | 5 + nsroot/array/concat.json | 5 + nsroot/array/declare.json | 5 + nsroot/array/delete-at.json | 5 + nsroot/array/delete.json | 5 + nsroot/array/filter.json | 5 + nsroot/array/iterate.json | 12 + nsroot/array/length.json | 5 + nsroot/array/push.json | 8 + nsroot/array/range.json | 8 + nsroot/array/replace.json | 5 + nsroot/array/set-element-at.json | 5 + nsroot/command/failure-check.json | 9 + nsroot/command/if-exists.json | 9 + nsroot/command/nice.json | 5 + nsroot/command/renice.json | 5 + nsroot/command/run.json | 5 + nsroot/command/success-check.json | 9 + nsroot/cryptography/base64-decode.json | 5 + nsroot/cryptography/base64-encode.json | 5 + nsroot/cryptography/hash.json | 5 + nsroot/date-time/day-of-month-current.json | 5 + nsroot/date-time/day-of-week-current.json | 5 + nsroot/date-time/day-of-year-current.json | 5 + nsroot/date-time/epoch-seconds.json | 5 + nsroot/date-time/local-time-current.json | 5 + nsroot/date-time/month-name-current.json | 5 + nsroot/date-time/month-number-current.json | 5 + nsroot/date-time/short.json | 5 + nsroot/date-time/time-utc.json | 5 + nsroot/date-time/utc.json | 5 + nsroot/date-time/year-current.json | 5 + .../filesystem/directory-create-nested.json | 5 + nsroot/filesystem/directory-create.json | 5 + nsroot/filesystem/file-delete.json | 8 + nsroot/filesystem/file-read.json | 9 + nsroot/filesystem/file-search.json | 9 + .../filesystem/file-write-multiline-sudo.json | 9 + nsroot/filesystem/file-write-multiline.json | 9 + nsroot/filesystem/file-write.json | 10 + .../filesystem/find-files-or-directories.json | 8 + nsroot/filesystem/if-directory-exists.json | 9 + nsroot/filesystem/if-file-executable.json | 9 + .../if-file-exists-and-is-symbolic-link.json | 9 + nsroot/filesystem/if-file-exists.json | 9 + nsroot/filesystem/if-file-not-empty.json | 9 + nsroot/filesystem/if-file-readable.json | 9 + nsroot/filesystem/if-file-writeable.json | 9 + .../filesystem/if-file1-newer-than-file2.json | 9 + .../filesystem/if-file1-older-than-file2.json | 9 + nsroot/filesystem/if-files-are-equal.json | 9 + nsroot/filesystem/if-path-exists.json | 9 + .../filesystem/remove-files-older-than.json | 5 + nsroot/fn-fx/fn-banner-color.json | 44 + nsroot/fn-fx/fn-banner-simple.json | 15 + nsroot/fn-fx/fn-import.json | 16 + nsroot/fn-fx/fn-math-average.json | 13 + nsroot/fn-fx/fn-math-product.json | 13 + nsroot/fn-fx/fn-math-sum.json | 13 + nsroot/fn-fx/fn-options.json | 47 + nsroot/fn-fx/fn-progress.json | 15 + nsroot/fn-fx/fn-scan.json | 12 + nsroot/fn-fx/fn-version-compare.json | 36 + nsroot/fn-fx/fx-banner-color.json | 5 + nsroot/fn-fx/fx-banner-simple.json | 5 + nsroot/fn-fx/fx-import.json | 5 + nsroot/fn-fx/fx-math-average.json | 5 + nsroot/fn-fx/fx-math-product.json | 5 + nsroot/fn-fx/fx-math-sum.json | 5 + nsroot/fn-fx/fx-options.json | 9 + nsroot/fn-fx/fx-progress.json | 5 + nsroot/fn-fx/fx-scan.json | 5 + nsroot/fn-fx/fx-version-compare.json | 8 + nsroot/ftp/delete.json | 5 + nsroot/ftp/download.json | 5 + nsroot/ftp/list-of-files.json | 5 + nsroot/ftp/rename.json | 5 + nsroot/ftp/upload.json | 5 + nsroot/function/arguments-array.json | 5 + nsroot/function/arguments-count.json | 5 + nsroot/function/declare.json | 9 + nsroot/function/return-value.json | 5 + nsroot/git/branch-create.json | 5 + nsroot/git/branch-delete-local.json | 5 + nsroot/git/branch-delete-remote.json | 5 + nsroot/git/branch-list.json | 5 + nsroot/git/branch-push.json | 5 + nsroot/git/branch-rename.json | 5 + nsroot/git/changes-revert.json | 5 + nsroot/git/clone-branch.json | 5 + nsroot/git/clone.json | 5 + nsroot/git/commit-list.json | 5 + nsroot/git/commit-search.json | 5 + nsroot/git/commit-undo.json | 5 + nsroot/git/commit.json | 5 + nsroot/git/config-list.json | 5 + nsroot/git/config-set.json | 5 + nsroot/git/patch-apply.json | 5 + nsroot/git/patch-create.json | 5 + nsroot/git/remote-list.json | 5 + nsroot/git/remote-url-change.json | 5 + nsroot/git/remote-urlAdd.json | 5 + nsroot/git/tag-commit.json | 8 + nsroot/git/tag-list.json | 5 + nsroot/git/tag-remote-delete.json | 5 + nsroot/git/tag-remote-push.json | 5 + nsroot/http/cookie.json | 10 + nsroot/http/download.json | 10 + nsroot/http/get.json | 12 + nsroot/http/header.json | 10 + nsroot/http/post-send-file.json | 11 + nsroot/http/post.json | 14 + nsroot/input/ask-question.json | 8 + nsroot/integer/if-equal.json | 9 + nsroot/integer/if-greater-or-equal.json | 9 + nsroot/integer/if-greater.json | 9 + nsroot/integer/if-lesser-or-equal.json | 9 + nsroot/integer/if-lesser.json | 9 + nsroot/integer/if-not-equal.json | 9 + nsroot/ip/array-of-local.json | 5 + nsroot/ip/info.json | 5 + nsroot/ip/public-address.json | 5 + nsroot/lang/for-i-j.json | 11 + nsroot/lang/for-i.json | 9 + nsroot/lang/for-in-collection.json | 9 + nsroot/lang/for-in-column.json | 10 + nsroot/lang/if-elif-else.json | 13 + nsroot/lang/if-not.json | 5 + nsroot/lang/if.json | 5 + nsroot/lang/switch.json | 17 + nsroot/lang/until.json | 9 + nsroot/lang/while.json | 9 + nsroot/math/add.json | 5 + nsroot/math/const-gamma.json | 5 + nsroot/math/const-napier.json | 5 + nsroot/math/const-omega.json | 5 + nsroot/math/const-phi.json | 5 + nsroot/math/const-pi.json | 5 + nsroot/math/decrement.json | 5 + nsroot/math/divide-equal.json | 5 + nsroot/math/divide.json | 5 + nsroot/math/float.json | 5 + nsroot/math/increment.json | 5 + nsroot/math/minus-equal.json | 5 + nsroot/math/modulus-equal.json | 5 + nsroot/math/modulus.json | 5 + nsroot/math/multiply-equal.json | 5 + nsroot/math/multiply.json | 5 + nsroot/math/plus-equal.json | 5 + nsroot/math/power.json | 5 + nsroot/math/random-number.json | 5 + nsroot/math/sqrt.json | 5 + nsroot/math/subtract.json | 5 + nsroot/misc/arguments-parse.json | 27 + nsroot/misc/expr.json | 5 + nsroot/misc/let.json | 5 + nsroot/misc/region.json | 9 + nsroot/misc/shebang.json | 8 + nsroot/misc/sleep.json | 5 + nsroot/misc/stopwatch-elapsed.json | 10 + nsroot/misc/stopwatch-start.json | 5 + nsroot/misc/stopwatch-stop.json | 5 + nsroot/misc/summary.json | 11 + nsroot/misc/timeout.json | 5 + nsroot/misc/variable-default-value.json | 5 + nsroot/output/color-black.json | 5 + nsroot/output/color-blue.json | 5 + nsroot/output/color-cyan.json | 5 + nsroot/output/color-green.json | 5 + nsroot/output/color-magenta.json | 5 + nsroot/output/color-red.json | 5 + nsroot/output/color-white.json | 5 + nsroot/output/color-yellow.json | 5 + nsroot/output/format-bold.json | 5 + nsroot/output/format-dim.json | 5 + nsroot/output/format-italic.json | 5 + nsroot/output/format-reverse.json | 5 + nsroot/string/contains.json | 12 + nsroot/string/first-index-substring.json | 8 + nsroot/string/if-empty.json | 9 + nsroot/string/if-equal.json | 12 + nsroot/string/if-not-empty.json | 9 + nsroot/string/if-not-equal.json | 12 + nsroot/string/length.json | 5 + nsroot/string/replace.json | 5 + nsroot/string/reverse.json | 5 + nsroot/string/substring-count.json | 8 + nsroot/string/substring.json | 5 + nsroot/string/to-lower.json | 5 + nsroot/string/to-upper.json | 5 + nsroot/string/trim-all.json | 5 + nsroot/string/trim-left.json | 5 + nsroot/string/trim-right.json | 5 + nsroot/string/trim.json | 5 + nsroot/system/distro-codename.json | 5 + nsroot/system/distro-name.json | 5 + nsroot/system/distro-version.json | 5 + nsroot/system/kernel-name.json | 5 + nsroot/system/kernel-release.json | 5 + nsroot/system/memory-info.json | 5 + nsroot/system/process-id.json | 5 + nsroot/system/process-kill.json | 5 + nsroot/system/process-list.json | 5 + nsroot/system/processor-architecture.json | 5 + nsroot/system/processor-count.json | 5 + nsroot/system/processor-model.json | 5 + nsroot/system/processor-type.json | 5 + nsroot/system/service-manage.json | 5 + nsroot/system/uptime.json | 5 + package-lock.json | 397 ++- package.json | 7 +- snippets/snippets.json | 3062 ++++++++--------- 224 files changed, 4627 insertions(+), 2911 deletions(-) create mode 100644 .vscode/tasks.json create mode 100644 build.js delete mode 100644 docgen.js create mode 100644 nsroot/README.md create mode 100644 nsroot/archive/compress-tar-gz.json create mode 100644 nsroot/archive/decompress-tar-gz.json create mode 100644 nsroot/array/all-elements.json create mode 100644 nsroot/array/at-index.json create mode 100644 nsroot/array/concat.json create mode 100644 nsroot/array/declare.json create mode 100644 nsroot/array/delete-at.json create mode 100644 nsroot/array/delete.json create mode 100644 nsroot/array/filter.json create mode 100644 nsroot/array/iterate.json create mode 100644 nsroot/array/length.json create mode 100644 nsroot/array/push.json create mode 100644 nsroot/array/range.json create mode 100644 nsroot/array/replace.json create mode 100644 nsroot/array/set-element-at.json create mode 100644 nsroot/command/failure-check.json create mode 100644 nsroot/command/if-exists.json create mode 100644 nsroot/command/nice.json create mode 100644 nsroot/command/renice.json create mode 100644 nsroot/command/run.json create mode 100644 nsroot/command/success-check.json create mode 100644 nsroot/cryptography/base64-decode.json create mode 100644 nsroot/cryptography/base64-encode.json create mode 100644 nsroot/cryptography/hash.json create mode 100644 nsroot/date-time/day-of-month-current.json create mode 100644 nsroot/date-time/day-of-week-current.json create mode 100644 nsroot/date-time/day-of-year-current.json create mode 100644 nsroot/date-time/epoch-seconds.json create mode 100644 nsroot/date-time/local-time-current.json create mode 100644 nsroot/date-time/month-name-current.json create mode 100644 nsroot/date-time/month-number-current.json create mode 100644 nsroot/date-time/short.json create mode 100644 nsroot/date-time/time-utc.json create mode 100644 nsroot/date-time/utc.json create mode 100644 nsroot/date-time/year-current.json create mode 100644 nsroot/filesystem/directory-create-nested.json create mode 100644 nsroot/filesystem/directory-create.json create mode 100644 nsroot/filesystem/file-delete.json create mode 100644 nsroot/filesystem/file-read.json create mode 100644 nsroot/filesystem/file-search.json create mode 100644 nsroot/filesystem/file-write-multiline-sudo.json create mode 100644 nsroot/filesystem/file-write-multiline.json create mode 100644 nsroot/filesystem/file-write.json create mode 100644 nsroot/filesystem/find-files-or-directories.json create mode 100644 nsroot/filesystem/if-directory-exists.json create mode 100644 nsroot/filesystem/if-file-executable.json create mode 100644 nsroot/filesystem/if-file-exists-and-is-symbolic-link.json create mode 100644 nsroot/filesystem/if-file-exists.json create mode 100644 nsroot/filesystem/if-file-not-empty.json create mode 100644 nsroot/filesystem/if-file-readable.json create mode 100644 nsroot/filesystem/if-file-writeable.json create mode 100644 nsroot/filesystem/if-file1-newer-than-file2.json create mode 100644 nsroot/filesystem/if-file1-older-than-file2.json create mode 100644 nsroot/filesystem/if-files-are-equal.json create mode 100644 nsroot/filesystem/if-path-exists.json create mode 100644 nsroot/filesystem/remove-files-older-than.json create mode 100644 nsroot/fn-fx/fn-banner-color.json create mode 100644 nsroot/fn-fx/fn-banner-simple.json create mode 100644 nsroot/fn-fx/fn-import.json create mode 100644 nsroot/fn-fx/fn-math-average.json create mode 100644 nsroot/fn-fx/fn-math-product.json create mode 100644 nsroot/fn-fx/fn-math-sum.json create mode 100644 nsroot/fn-fx/fn-options.json create mode 100644 nsroot/fn-fx/fn-progress.json create mode 100644 nsroot/fn-fx/fn-scan.json create mode 100644 nsroot/fn-fx/fn-version-compare.json create mode 100644 nsroot/fn-fx/fx-banner-color.json create mode 100644 nsroot/fn-fx/fx-banner-simple.json create mode 100644 nsroot/fn-fx/fx-import.json create mode 100644 nsroot/fn-fx/fx-math-average.json create mode 100644 nsroot/fn-fx/fx-math-product.json create mode 100644 nsroot/fn-fx/fx-math-sum.json create mode 100644 nsroot/fn-fx/fx-options.json create mode 100644 nsroot/fn-fx/fx-progress.json create mode 100644 nsroot/fn-fx/fx-scan.json create mode 100644 nsroot/fn-fx/fx-version-compare.json create mode 100644 nsroot/ftp/delete.json create mode 100644 nsroot/ftp/download.json create mode 100644 nsroot/ftp/list-of-files.json create mode 100644 nsroot/ftp/rename.json create mode 100644 nsroot/ftp/upload.json create mode 100644 nsroot/function/arguments-array.json create mode 100644 nsroot/function/arguments-count.json create mode 100644 nsroot/function/declare.json create mode 100644 nsroot/function/return-value.json create mode 100644 nsroot/git/branch-create.json create mode 100644 nsroot/git/branch-delete-local.json create mode 100644 nsroot/git/branch-delete-remote.json create mode 100644 nsroot/git/branch-list.json create mode 100644 nsroot/git/branch-push.json create mode 100644 nsroot/git/branch-rename.json create mode 100644 nsroot/git/changes-revert.json create mode 100644 nsroot/git/clone-branch.json create mode 100644 nsroot/git/clone.json create mode 100644 nsroot/git/commit-list.json create mode 100644 nsroot/git/commit-search.json create mode 100644 nsroot/git/commit-undo.json create mode 100644 nsroot/git/commit.json create mode 100644 nsroot/git/config-list.json create mode 100644 nsroot/git/config-set.json create mode 100644 nsroot/git/patch-apply.json create mode 100644 nsroot/git/patch-create.json create mode 100644 nsroot/git/remote-list.json create mode 100644 nsroot/git/remote-url-change.json create mode 100644 nsroot/git/remote-urlAdd.json create mode 100644 nsroot/git/tag-commit.json create mode 100644 nsroot/git/tag-list.json create mode 100644 nsroot/git/tag-remote-delete.json create mode 100644 nsroot/git/tag-remote-push.json create mode 100644 nsroot/http/cookie.json create mode 100644 nsroot/http/download.json create mode 100644 nsroot/http/get.json create mode 100644 nsroot/http/header.json create mode 100644 nsroot/http/post-send-file.json create mode 100644 nsroot/http/post.json create mode 100644 nsroot/input/ask-question.json create mode 100644 nsroot/integer/if-equal.json create mode 100644 nsroot/integer/if-greater-or-equal.json create mode 100644 nsroot/integer/if-greater.json create mode 100644 nsroot/integer/if-lesser-or-equal.json create mode 100644 nsroot/integer/if-lesser.json create mode 100644 nsroot/integer/if-not-equal.json create mode 100644 nsroot/ip/array-of-local.json create mode 100644 nsroot/ip/info.json create mode 100644 nsroot/ip/public-address.json create mode 100644 nsroot/lang/for-i-j.json create mode 100644 nsroot/lang/for-i.json create mode 100644 nsroot/lang/for-in-collection.json create mode 100644 nsroot/lang/for-in-column.json create mode 100644 nsroot/lang/if-elif-else.json create mode 100644 nsroot/lang/if-not.json create mode 100644 nsroot/lang/if.json create mode 100644 nsroot/lang/switch.json create mode 100644 nsroot/lang/until.json create mode 100644 nsroot/lang/while.json create mode 100644 nsroot/math/add.json create mode 100644 nsroot/math/const-gamma.json create mode 100644 nsroot/math/const-napier.json create mode 100644 nsroot/math/const-omega.json create mode 100644 nsroot/math/const-phi.json create mode 100644 nsroot/math/const-pi.json create mode 100644 nsroot/math/decrement.json create mode 100644 nsroot/math/divide-equal.json create mode 100644 nsroot/math/divide.json create mode 100644 nsroot/math/float.json create mode 100644 nsroot/math/increment.json create mode 100644 nsroot/math/minus-equal.json create mode 100644 nsroot/math/modulus-equal.json create mode 100644 nsroot/math/modulus.json create mode 100644 nsroot/math/multiply-equal.json create mode 100644 nsroot/math/multiply.json create mode 100644 nsroot/math/plus-equal.json create mode 100644 nsroot/math/power.json create mode 100644 nsroot/math/random-number.json create mode 100644 nsroot/math/sqrt.json create mode 100644 nsroot/math/subtract.json create mode 100644 nsroot/misc/arguments-parse.json create mode 100644 nsroot/misc/expr.json create mode 100644 nsroot/misc/let.json create mode 100644 nsroot/misc/region.json create mode 100644 nsroot/misc/shebang.json create mode 100644 nsroot/misc/sleep.json create mode 100644 nsroot/misc/stopwatch-elapsed.json create mode 100644 nsroot/misc/stopwatch-start.json create mode 100644 nsroot/misc/stopwatch-stop.json create mode 100644 nsroot/misc/summary.json create mode 100644 nsroot/misc/timeout.json create mode 100644 nsroot/misc/variable-default-value.json create mode 100644 nsroot/output/color-black.json create mode 100644 nsroot/output/color-blue.json create mode 100644 nsroot/output/color-cyan.json create mode 100644 nsroot/output/color-green.json create mode 100644 nsroot/output/color-magenta.json create mode 100644 nsroot/output/color-red.json create mode 100644 nsroot/output/color-white.json create mode 100644 nsroot/output/color-yellow.json create mode 100644 nsroot/output/format-bold.json create mode 100644 nsroot/output/format-dim.json create mode 100644 nsroot/output/format-italic.json create mode 100644 nsroot/output/format-reverse.json create mode 100644 nsroot/string/contains.json create mode 100644 nsroot/string/first-index-substring.json create mode 100644 nsroot/string/if-empty.json create mode 100644 nsroot/string/if-equal.json create mode 100644 nsroot/string/if-not-empty.json create mode 100644 nsroot/string/if-not-equal.json create mode 100644 nsroot/string/length.json create mode 100644 nsroot/string/replace.json create mode 100644 nsroot/string/reverse.json create mode 100644 nsroot/string/substring-count.json create mode 100644 nsroot/string/substring.json create mode 100644 nsroot/string/to-lower.json create mode 100644 nsroot/string/to-upper.json create mode 100644 nsroot/string/trim-all.json create mode 100644 nsroot/string/trim-left.json create mode 100644 nsroot/string/trim-right.json create mode 100644 nsroot/string/trim.json create mode 100644 nsroot/system/distro-codename.json create mode 100644 nsroot/system/distro-name.json create mode 100644 nsroot/system/distro-version.json create mode 100644 nsroot/system/kernel-name.json create mode 100644 nsroot/system/kernel-release.json create mode 100644 nsroot/system/memory-info.json create mode 100644 nsroot/system/process-id.json create mode 100644 nsroot/system/process-kill.json create mode 100644 nsroot/system/process-list.json create mode 100644 nsroot/system/processor-architecture.json create mode 100644 nsroot/system/processor-count.json create mode 100644 nsroot/system/processor-model.json create mode 100644 nsroot/system/processor-type.json create mode 100644 nsroot/system/service-manage.json create mode 100644 nsroot/system/uptime.json diff --git a/.gitignore b/.gitignore index d7cb55b..0a18f44 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -node_modules +node_modules/ # .vscode/ *.vsix diff --git a/.vscode/launch.json b/.vscode/launch.json index 7bc18a4..29f539f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -3,8 +3,17 @@ // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 { - "version": "0.2.0", + "version": "0.2.0", "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Build", + "program": "${workspaceFolder}/build.js", + "skipFiles": [ + "/**" + ] + }, { "name": "Extension", "type": "extensionHost", diff --git a/.vscode/settings.json b/.vscode/settings.json index b959b14..f9a9328 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -33,6 +33,7 @@ "mobi", "multiline", "mylib", + "nsroot", "pgrep", "proto", "quickstart", diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..6e1b753 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,12 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "npm", + "script": "spellcheck", + "problemMatcher": [], + "label": "npm: spellcheck", + "detail": "./node_modules/.bin/cspell ./**/*" + } + ] +} \ No newline at end of file diff --git a/.vscodeignore b/.vscodeignore index 2b00e2b..4ccd1fb 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -1,8 +1,9 @@ .vscode/** -.vscode-test/** -.gitignore +node_modules/** +nsroot/** +_config.yml .gitattributes -docgen.js +.gitignore +build.js publish.sh -_config.yml test.sh diff --git a/COMMANDS.md b/COMMANDS.md index 09dc734..918341d 100644 --- a/COMMANDS.md +++ b/COMMANDS.md @@ -1,566 +1,499 @@ # Commands -- [bash](#bash) +- archive -- [summary](#summary) + - [archive compress tar.gz](#archive-compress-tar.gz) -- [argument parsing](#argument-parsing) + - [archive decompress tar.gz](#archive-decompress-tar.gz) -- [func](#func) +- array -- [func args count](#func-args-count) + - [array all](#array-all) -- [func args](#func-args) + - [array at index](#array-at-index) -- [func ret val](#func-ret-val) + - [array concat](#array-concat) -- [cmd](#cmd) + - [array declare](#array-declare) -- [cmd nice](#cmd-nice) + - [array delete at](#array-delete-at) -- [cmd renice](#cmd-renice) + - [array delete](#array-delete) -- [cmd success check](#cmd-success-check) + - [array filter](#array-filter) -- [cmd failure check](#cmd-failure-check) + - [array iterate](#array-iterate) -- [archive compress tar.gz](#archive-compress-tar.gz) + - [array length](#array-length) -- [archive decompress tar.gz](#archive-decompress-tar.gz) + - [array push](#array-push) -- [array concat](#array-concat) + - [array slice](#array-slice) -- [array declare](#array-declare) + - [array replace](#array-replace) -- [array delete](#array-delete) + - [array set element](#array-set-element) -- [array delete at](#array-delete-at) +- command -- [array all](#array-all) + - [cmd failure check](#cmd-failure-check) -- [array filter](#array-filter) + - [if cmd exists](#if-cmd-exists) -- [array push](#array-push) + - [cmd nice](#cmd-nice) -- [array replace](#array-replace) + - [cmd renice](#cmd-renice) -- [array at index](#array-at-index) + - [cmd](#cmd) -- [array iterate](#array-iterate) + - [cmd success check](#cmd-success-check) -- [array length](#array-length) +- cryptography -- [array slice](#array-slice) + - [crypto base64 decode](#crypto-base64-decode) -- [array set element](#array-set-element) + - [crypto base64 encode](#crypto-base64-encode) -- [assign if empty](#assign-if-empty) + - [crypto hash](#crypto-hash) -- [ask question](#ask-question) +- date-time -- [crypto base64 encode](#crypto-base64-encode) + - [date now dayOfMonth](#date-now-dayOfMonth) -- [crypto base64 decode](#crypto-base64-decode) + - [date now dayOfWeek](#date-now-dayOfWeek) -- [crypto hash](#crypto-hash) + - [date now dayOfYear](#date-now-dayOfYear) -- [date now short](#date-now-short) + - [time seconds epoch](#time-seconds-epoch) -- [date now UTC](#date-now-UTC) + - [time now local](#time-now-local) -- [date now year](#date-now-year) + - [date now monthName](#date-now-monthName) -- [date now monthNumber](#date-now-monthNumber) + - [date now monthNumber](#date-now-monthNumber) -- [date now monthName](#date-now-monthName) + - [date now short](#date-now-short) -- [date now dayOfMonth](#date-now-dayOfMonth) + - [time now UTC](#time-now-UTC) -- [date now dayOfWeek](#date-now-dayOfWeek) + - [date now UTC](#date-now-UTC) -- [date now dayOfYear](#date-now-dayOfYear) + - [date now year](#date-now-year) -- [time now local](#time-now-local) +- filesystem -- [time now UTC](#time-now-UTC) + - [directory create nested](#directory-create-nested) -- [time seconds epoch](#time-seconds-epoch) + - [directory create](#directory-create) -- [directory create](#directory-create) + - [file delete](#file-delete) -- [directory create nested](#directory-create-nested) + - [file read](#file-read) -- [git branch list](#git-branch-list) + - [file search](#file-search) -- [git branch create](#git-branch-create) + - [file write multiline sudo](#file-write-multiline-sudo) -- [git branch delete local](#git-branch-delete-local) + - [file write multiline](#file-write-multiline) -- [git branch delete remote](#git-branch-delete-remote) + - [file write](#file-write) -- [git branch push](#git-branch-push) + - [file find](#file-find) -- [git branch rename](#git-branch-rename) + - [if directory exists](#if-directory-exists) -- [git changes revert](#git-changes-revert) + - [if file executable](#if-file-executable) -- [git clone](#git-clone) + - [if file link](#if-file-link) -- [git clone branch](#git-clone-branch) + - [if file exists](#if-file-exists) -- [git commit](#git-commit) + - [if file not empty](#if-file-not-empty) -- [git commit list notPushed](#git-commit-list-notPushed) + - [if file readable](#if-file-readable) -- [git commit search](#git-commit-search) + - [if file writeable](#if-file-writeable) -- [git commit undo](#git-commit-undo) + - [if file newer](#if-file-newer) -- [git config list](#git-config-list) + - [if file older](#if-file-older) -- [git config set](#git-config-set) + - [if file =](#if-file-=) -- [git patch apply](#git-patch-apply) + - [if exists](#if-exists) -- [git patch create](#git-patch-create) + - [remove files older](#remove-files-older) -- [git remote list](#git-remote-list) +- fn-fx -- [git remote urlAdd](#git-remote-urlAdd) + - [fn banner color](#fn-banner-color) -- [git remote urlChange](#git-remote-urlChange) + - [fn banner simple](#fn-banner-simple) -- [git tag list](#git-tag-list) + - [fn import](#fn-import) -- [git tag commit](#git-tag-commit) + - [fn math average](#fn-math-average) -- [git tag remote delete](#git-tag-remote-delete) + - [fn math product](#fn-math-product) -- [git tag remote push](#git-tag-remote-push) + - [fn math sum](#fn-math-sum) -- [http GET](#http-GET) + - [fn options](#fn-options) -- [http POST](#http-POST) + - [fn progress](#fn-progress) -- [http POST file](#http-POST-file) + - [fn scan](#fn-scan) -- [http header](#http-header) + - [fn version compare](#fn-version-compare) -- [http cookie](#http-cookie) + - [fx banner color](#fx-banner-color) -- [http download](#http-download) + - [fx banner simple](#fx-banner-simple) -- [ftp list](#ftp-list) + - [fx import](#fx-import) -- [ftp download](#ftp-download) + - [fx math average](#fx-math-average) -- [ftp upload](#ftp-upload) + - [fx math product](#fx-math-product) -- [ftp delete file](#ftp-delete-file) + - [fx math sum](#fx-math-sum) -- [ftp rename](#ftp-rename) + - [fx options](#fx-options) -- [if](#if) + - [fx progress](#fx-progress) -- [iff](#iff) + - [fx scan](#fx-scan) -- [iff not](#iff-not) + - [fx version compare](#fx-version-compare) -- [if string empty](#if-string-empty) +- ftp -- [if string not empty](#if-string-not-empty) + - [ftp delete file](#ftp-delete-file) -- [if string =](#if-string-=) + - [ftp download](#ftp-download) -- [if string !=](#if-string-!=) + - [ftp list](#ftp-list) -- [string length](#string-length) + - [ftp rename](#ftp-rename) -- [string trim](#string-trim) + - [ftp upload](#ftp-upload) -- [string trim left](#string-trim-left) +- function -- [string trim right](#string-trim-right) + - [func args](#func-args) -- [string trim all](#string-trim-all) + - [func args count](#func-args-count) -- [string replace](#string-replace) + - [func](#func) -- [string reverse](#string-reverse) + - [func ret val](#func-ret-val) -- [string toLower](#string-toLower) +- git -- [string toUpper](#string-toUpper) + - [git branch create](#git-branch-create) -- [string substring](#string-substring) + - [git branch delete local](#git-branch-delete-local) -- [string contains](#string-contains) + - [git branch delete remote](#git-branch-delete-remote) -- [string substring count](#string-substring-count) + - [git branch list](#git-branch-list) -- [string indexOf](#string-indexOf) + - [git branch push](#git-branch-push) -- [if int =](#if-int-=) + - [git branch rename](#git-branch-rename) -- [if int !=](#if-int-!=) + - [git changes revert](#git-changes-revert) -- [if int >](#if-int->) + - [git clone branch](#git-clone-branch) -- [if int >=](#if-int->=) + - [git clone](#git-clone) -- [if int <](#if-int-<) + - [git commit list notPushed](#git-commit-list-notPushed) -- [if int <=](#if-int-<=) + - [git commit search](#git-commit-search) -- [if cmd exists](#if-cmd-exists) + - [git commit undo](#git-commit-undo) -- [if exists](#if-exists) + - [git commit](#git-commit) -- [if file exists](#if-file-exists) + - [git config list](#git-config-list) -- [if file not empty](#if-file-not-empty) + - [git config set](#git-config-set) -- [if directory exists](#if-directory-exists) + - [git patch apply](#git-patch-apply) -- [if file readable](#if-file-readable) + - [git patch create](#git-patch-create) -- [if file writeable](#if-file-writeable) + - [git remote list](#git-remote-list) -- [if file executable](#if-file-executable) + - [git remote urlChange](#git-remote-urlChange) -- [if file =](#if-file-=) + - [git remote urlAdd](#git-remote-urlAdd) -- [if file link](#if-file-link) + - [git tag commit](#git-tag-commit) -- [if file newer](#if-file-newer) + - [git tag list](#git-tag-list) -- [if file older](#if-file-older) + - [git tag remote delete](#git-tag-remote-delete) -- [ips](#ips) + - [git tag remote push](#git-tag-remote-push) -- [ip info](#ip-info) +- http -- [ip public](#ip-public) + - [http cookie](#http-cookie) -- [for i](#for-i) + - [http download](#http-download) -- [for ij](#for-ij) + - [http GET](#http-GET) -- [for in](#for-in) + - [http header](#http-header) -- [for in column](#for-in-column) + - [http POST file](#http-POST-file) -- [while](#while) + - [http POST](#http-POST) -- [until](#until) +- input -- [switch case](#switch-case) + - [ask question](#ask-question) -- [let](#let) +- integer -- [expr](#expr) + - [if int =](#if-int-=) -- [math ++](#math-++) + - [if int >=](#if-int->=) -- [math --](#math---) + - [if int >](#if-int->) -- [math +](#math-+) + - [if int <=](#if-int-<=) -- [math +=](#math-+=) + - [if int <](#if-int-<) -- [math -](#math--) + - [if int !=](#if-int-!=) -- [math -=](#math--=) +- ip -- [math *](#math-*) + - [ips](#ips) -- [math *=](#math-*=) + - [ip info](#ip-info) -- [math /](#math-/) + - [ip public](#ip-public) -- [math /=](#math-/=) +- lang -- [math %](#math-%) + - [for ij](#for-ij) -- [math %=](#math-%=) + - [for i](#for-i) -- [math ^](#math-^) + - [for in](#for-in) -- [math random](#math-random) + - [for in column](#for-in-column) -- [math √](#math-√) + - [if](#if) -- [math 0.00](#math-0.00) + - [iff not](#iff-not) -- [math const π](#math-const-π) + - [iff](#iff) -- [math const e](#math-const-e) + - [switch case](#switch-case) -- [math const 𝛾](#math-const-𝛾) + - [until](#until) -- [math const ϕ](#math-const-ϕ) + - [while](#while) -- [math const Ω](#math-const-Ω) +- math -- [file delete](#file-delete) + - [math +](#math-+) -- [file find](#file-find) + - [math const 𝛾](#math-const-𝛾) -- [file read](#file-read) + - [math const e](#math-const-e) -- [file search](#file-search) + - [math const Ω](#math-const-Ω) -- [file write](#file-write) + - [math const ϕ](#math-const-ϕ) -- [file write multiline](#file-write-multiline) + - [math const π](#math-const-π) -- [file write multiline sudo](#file-write-multiline-sudo) + - [math --](#math---) -- [remove files older](#remove-files-older) + - [math /=](#math-/=) -- [color black](#color-black) + - [math /](#math-/) -- [color red](#color-red) + - [math 0.00](#math-0.00) -- [color green](#color-green) + - [math ++](#math-++) -- [color yellow](#color-yellow) + - [math -=](#math--=) -- [color blue](#color-blue) + - [math %=](#math-%=) -- [color magenta](#color-magenta) + - [math %](#math-%) -- [color cyan](#color-cyan) + - [math *=](#math-*=) -- [color white](#color-white) + - [math *](#math-*) -- [format bold](#format-bold) + - [math +=](#math-+=) -- [format italic](#format-italic) + - [math ^](#math-^) -- [format dim](#format-dim) + - [math random](#math-random) -- [format reverse](#format-reverse) + - [math √](#math-√) -- [process list](#process-list) + - [math -](#math--) -- [process ID](#process-ID) +- misc -- [process kill](#process-kill) + - [argument parsing](#argument-parsing) -- [region](#region) + - [expr](#expr) -- [service manage](#service-manage) + - [let](#let) -- [stopwatch start](#stopwatch-start) + - [region](#region) -- [stopwatch stop](#stopwatch-stop) + - [bash](#bash) -- [stopwatch elapsed](#stopwatch-elapsed) + - [sleep](#sleep) -- [sleep](#sleep) + - [stopwatch elapsed](#stopwatch-elapsed) -- [system memory info](#system-memory-info) + - [stopwatch start](#stopwatch-start) -- [system distro name](#system-distro-name) + - [stopwatch stop](#stopwatch-stop) -- [system distro version](#system-distro-version) + - [summary](#summary) -- [system distro codename](#system-distro-codename) + - [timeout](#timeout) -- [system kernel name](#system-kernel-name) + - [assign if empty](#assign-if-empty) -- [system kernel release](#system-kernel-release) +- output -- [system processor type](#system-processor-type) + - [color black](#color-black) -- [system processor count](#system-processor-count) + - [color blue](#color-blue) -- [system processor architecture](#system-processor-architecture) + - [color cyan](#color-cyan) -- [system processor model](#system-processor-model) + - [color green](#color-green) -- [system uptime](#system-uptime) + - [color magenta](#color-magenta) -- [timeout](#timeout) + - [color red](#color-red) -- [fn banner simple](#fn-banner-simple) + - [color white](#color-white) -- [fx banner simple](#fx-banner-simple) + - [color yellow](#color-yellow) -- [fn banner color](#fn-banner-color) + - [format bold](#format-bold) -- [fx banner color](#fx-banner-color) + - [format dim](#format-dim) -- [fn import](#fn-import) + - [format italic](#format-italic) -- [fx import](#fx-import) + - [format reverse](#format-reverse) -- [fn math sum](#fn-math-sum) +- string -- [fx math sum](#fx-math-sum) + - [string contains](#string-contains) -- [fn math product](#fn-math-product) + - [string indexOf](#string-indexOf) -- [fx math product](#fx-math-product) + - [if string empty](#if-string-empty) -- [fn math average](#fn-math-average) + - [if string =](#if-string-=) -- [fx math average](#fx-math-average) + - [if string not empty](#if-string-not-empty) -- [fn options](#fn-options) + - [if string !=](#if-string-!=) -- [fx options](#fx-options) + - [string length](#string-length) -- [fn progress](#fn-progress) + - [string replace](#string-replace) -- [fx progress](#fx-progress) + - [string reverse](#string-reverse) -- [fn scan](#fn-scan) + - [string substring count](#string-substring-count) -- [fx scan](#fx-scan) + - [string substring](#string-substring) -- [fn version compare](#fn-version-compare) + - [string toLower](#string-toLower) -- [fx version compare](#fx-version-compare) + - [string toUpper](#string-toUpper) -## `bash,shebang` - -bash shebang [↑](#Commands) - -```bash -#!/usr/bin/env ${1|bash,node,perl,php,python,python3,ruby|} -``` - -## `summary` - -script summary [↑](#Commands) - -```bash -# Title: title -# Description: description -# Author: author -# Date: yyyy-mm-dd -# Version: 1.0.0 -``` - -## `argument parsing,parse args` - -parse command line arguments (flags/switches) [↑](#Commands) - -```bash -POSITIONAL=() -while [[ $# > 0 ]]; do - case "$1" in - -f|--flag) - echo flag: $1 - shift # shift once since flags have no values - ;; - -s|--switch) - echo switch $1 with value: $2 - shift 2 # shift twice to bypass switch and its value - ;; - *) # unknown flag/switch - POSITIONAL+=("$1") - shift - ;; - esac -done -set -- "${POSITIONAL[@]}" # restore positional params -``` - -## `func` - -function [↑](#Commands) + - [string trim all](#string-trim-all) -```bash -function name () { - echo "$1" # arguments are accessible through $1, $2,... -} -``` + - [string trim left](#string-trim-left) -## `func args count` + - [string trim right](#string-trim-right) -number of function arguments [↑](#Commands) + - [string trim](#string-trim) -```bash -echo $# -``` +- system -## `func args` + - [system distro codename](#system-distro-codename) -function arguments array [↑](#Commands) + - [system distro name](#system-distro-name) -```bash -echo "$@" -``` + - [system distro version](#system-distro-version) -## `func ret val` + - [system kernel name](#system-kernel-name) -last function/command return code [↑](#Commands) + - [system kernel release](#system-kernel-release) -```bash -echo "$?" -``` + - [system memory info](#system-memory-info) -## `cmd` + - [process ID](#process-ID) -run command (command substitution) [↑](#Commands) + - [process kill](#process-kill) -```bash -`command` -``` + - [process list](#process-list) -## `cmd nice` + - [system processor architecture](#system-processor-architecture) -run command with desired privilege. n: -20 (highest priority) to 19 (lowest priority) [↑](#Commands) + - [system processor count](#system-processor-count) -```bash -sudo nice -n ${1|-20,-15,-10,-5,0,5,10,15,19|} command -``` + - [system processor model](#system-processor-model) -## `cmd renice` + - [system processor type](#system-processor-type) -Change running process priority. n: -20 (highest priority) to 19 (lowest priority) [↑](#Commands) + - [service manage](#service-manage) -```bash -sudo renice -n ${1|-20,-15,-10,-5,0,5,10,15,19|} -p `pgrep process_name` -``` + - [system uptime](#system-uptime) -## `cmd success check` +## `archive compress tar.gz` -check if last command succeed [↑](#Commands) +compress file/folder to a .tar.gz file [↑](#Commands) ```bash -if [[ $? == 0 ]]; then - echo command succeed -fi +tar -czvf /path/to/archive.tar.gz /path/to/directory-or-file ``` -## `cmd failure check` +## `archive decompress tar.gz` -check if last command failed [↑](#Commands) +decompress a .tar.gz file to specified path [↑](#Commands) ```bash -if [[ $? != 0 ]]; then - echo command failed -fi +tar -C /extract/to/path -xzvf /path/to/archive.tar.gz ``` -## `archive compress tar.gz` +## `array all` -compress file/folder to a .tar.gz file [↑](#Commands) +all array elements [↑](#Commands) ```bash -tar -czvf /path/to/archive.tar.gz /path/to/directory-or-file +${myArray[@]} ``` -## `archive decompress tar.gz` +## `array at index` -decompress a .tar.gz file to specified path [↑](#Commands) +retrieve element at specified index (zero based) [↑](#Commands) ```bash -tar -C /extract/to/path -xzvf /path/to/archive.tar.gz +${myArray[index]} ``` ## `array concat` @@ -579,14 +512,6 @@ declare an array [↑](#Commands) myArray=('one' 'two' 'three') ``` -## `array delete` - -delete entire array [↑](#Commands) - -```bash -unset myArray -``` - ## `array delete at` delete element at index from array [↑](#Commands) @@ -595,12 +520,12 @@ delete element at index from array [↑](#Commands) unset myArray[index] ``` -## `array all` +## `array delete` -all array elements [↑](#Commands) +delete entire array [↑](#Commands) ```bash -${myArray[@]} +unset myArray ``` ## `array filter` @@ -611,30 +536,6 @@ filter elements of an array based on given pattern [↑](#Commands) filtered=(`for i in ${myArray[@]} ; do echo $i; done | grep pattern`) ``` -## `array push,array add` - -push new item to the end of array [↑](#Commands) - -```bash -myArray+=('newItem') -``` - -## `array replace` - -find and replace elements in array using regex [↑](#Commands) - -```bash -${myArray[@]//find/replace} -``` - -## `array at index` - -retrieve element at specified index (zero based) [↑](#Commands) - -```bash -${myArray[index]} -``` - ## `array iterate,array forEach` iterate array elements [↑](#Commands) @@ -653,6 +554,14 @@ length of array [↑](#Commands) ${#myArray[@]} ``` +## `array push,array add` + +push new item to the end of array [↑](#Commands) + +```bash +myArray+=('newItem') +``` + ## `array slice,array range` elements of array from index, equal to count numbers [↑](#Commands) @@ -661,93 +570,98 @@ elements of array from index, equal to count numbers [↑](#Commands) ${myArray[@]:from:count} ``` -## `array set element` +## `array replace` -set array element at index [↑](#Commands) +find and replace elements in array using regex [↑](#Commands) ```bash -myArray[index]=value +${myArray[@]//find/replace} ``` -## `assign if empty` +## `array set element` -assign default to variable if variable is empty or null [↑](#Commands) +set array element at index [↑](#Commands) ```bash -: "${variable:=default}" +myArray[index]=value ``` -## `ask question` +## `cmd failure check` -Ask question with default answer [↑](#Commands) +check if last command failed [↑](#Commands) ```bash -read -ep "Question here? " -i Default answer ANSWER -echo "$ANSWER" +if [[ $? != 0 ]]; then + echo command failed +fi ``` -## `crypto base64 encode` +## `if cmd exists` -encode variable to base64 [↑](#Commands) +check if command exists [↑](#Commands) ```bash -base64Encoded=`echo -n "$variableToEncode" | base64` +if [ `command -v command` ]; then + # body +fi ``` -## `crypto base64 decode` +## `cmd nice` -decode variable from base64 [↑](#Commands) +run command with desired privilege. n: -20 (highest priority) to 19 (lowest priority) [↑](#Commands) ```bash -base64Decoded=`echo -n "$variableToDecode" | base64 -d` +sudo nice -n ${1|-20,-15,-10,-5,0,5,10,15,19|} command ``` -## `crypto hash` +## `cmd renice` -compute hash of variable (md5, sha, sha1, sha224, sha256, sha384, sha512) [↑](#Commands) +Change running process priority. n: -20 (highest priority) to 19 (lowest priority) [↑](#Commands) ```bash -hash=`echo -n "$variableToHash" | ${3|md5sum,shasum,sha1sum,sha224sum,sha256sum,sha384sum,sha512sum|} | cut -f1 -d ' '` +for p in $(pidof "${process_name}"); do sudo renice -n ${1|-20,-15,-10,-5,0,5,10,15,19|} -p $p; done ``` -## `date now short` +## `cmd` -yyyy/mm/dd [↑](#Commands) +run command (command substitution) [↑](#Commands) ```bash -dateShort=`date -I` +$(command) ``` -## `date now UTC` +## `cmd success check` -coordinated Universal Time [↑](#Commands) +check if last command succeed [↑](#Commands) ```bash -dateUTC=`date -u` +if [[ $? == 0 ]]; then + echo command succeed +fi ``` -## `date now year` +## `crypto base64 decode` -current Year [↑](#Commands) +decode variable from base64 [↑](#Commands) ```bash -year=`date +%Y` +base64Decoded=`echo -n "$variableToDecode" | base64 -d` ``` -## `date now monthNumber` +## `crypto base64 encode` -current month number (1..12) [↑](#Commands) +encode variable to base64 [↑](#Commands) ```bash -monthNumber=`date +%m` +base64Encoded=`echo -n "$variableToEncode" | base64` ``` -## `date now monthName` +## `crypto hash` -current month name (full/abbreviated B/b) [↑](#Commands) +compute hash of variable (md5, sha, sha1, sha224, sha256, sha384, sha512) [↑](#Commands) ```bash -monthName=`date +%${1|B,b|}` +hash=`echo -n "$variableToHash" | ${3|md5sum,shasum,sha1sum,sha224sum,sha256sum,sha384sum,sha512sum|} | cut -f1 -d ' '` ``` ## `date now dayOfMonth` @@ -774,6 +688,14 @@ current day of year (1..366) [↑](#Commands) dayOfYear=`date +%j` ``` +## `time seconds epoch` + +seconds since epoch (1970-01-01 00:00:00) [↑](#Commands) + +```bash +timeNowSecondsEpoch=`date +%s` +``` + ## `time now local` current local time (24hrs/12hrs R/r) [↑](#Commands) @@ -782,957 +704,1109 @@ current local time (24hrs/12hrs R/r) [↑](#Commands) timeNowLocal=`date +%${1|R,r|}` ``` -## `time now UTC` +## `date now monthName` -current UTC time [↑](#Commands) +current month name (full/abbreviated B/b) [↑](#Commands) ```bash -timeNowUTC=`date -u +%R` +monthName=`date +%${1|B,b|}` ``` -## `time seconds epoch` +## `date now monthNumber` -seconds since epoch (1970-01-01 00:00:00) [↑](#Commands) +current month number (1..12) [↑](#Commands) ```bash -timeNowSecondsEpoch=`date +%s` +monthNumber=`date +%m` ``` -## `directory create` +## `date now short` -create directory [↑](#Commands) +yyyy/mm/dd [↑](#Commands) ```bash -mkdir "dirname" +dateShort=`date -I` ``` -## `directory create nested` +## `time now UTC` -create nested directories [↑](#Commands) +current UTC time [↑](#Commands) ```bash -mkdir -p "parent dir"/"child dir" +timeNowUTC=`date -u +%R` ``` -## `git branch list` +## `date now UTC` -List all branches. [↑](#Commands) +coordinated Universal Time [↑](#Commands) ```bash -git branch +dateUTC=`date -u` ``` -## `git branch create` +## `date now year` -Create branch locally and switch into it. [↑](#Commands) +current Year [↑](#Commands) ```bash -git checkout -b branchName +year=`date +%Y` ``` -## `git branch delete local` +## `directory create nested` -Delete local branch. [↑](#Commands) +create nested directories [↑](#Commands) ```bash -git branch --delete localBranch +mkdir -p "parent dir"/"child dir" ``` -## `git branch delete remote` +## `directory create` -Delete remote branch. [↑](#Commands) +create directory [↑](#Commands) ```bash -git push origin --delete remoteBranch +mkdir "dirname" ``` -## `git branch push` +## `file delete,file remove` -Push branch to remote. [↑](#Commands) +delete file(s) [↑](#Commands) ```bash -git push origin branchName +rm -f ./path/file ``` -## `git branch rename` +## `file read` -Rename current branch. [↑](#Commands) +read a file [↑](#Commands) ```bash -git branch -m newName +cat "$filepath" | while read line; do + echo "$line" +done ``` -## `git changes revert` +## `file search,search in files,find in files` -Revert tracked changes [↑](#Commands) +find files which contain search criteria [↑](#Commands) ```bash -git checkout . +result=`find ./path -maxdepth ${2|0,1,2,3,4,5,6,7,8,9|} -type f -exec grep "criteria" {} +` ``` -## `git clone` +## `file write multiline sudo` -Clone remote repository to local machine. [↑](#Commands) +write multiple lines into file with sudo permission [↑](#Commands) ```bash -git clone https://github.com/user/repository.git +cat << EOL | sudo tee filepath +# text here +EOL ``` -## `git clone branch` +## `file write multiline` -Clone a remote branch to local machine. [↑](#Commands) +write multiple lines into file [↑](#Commands) ```bash -git clone -b branchName https://github.com/user/repository.git +cat >filepath < ${2:/path/to/file} +for line in ${lines}; do + echo "$line" >> /path/to/file +done ``` -## `git commit list notPushed` +## `file find,directory find` -List non pushed commits. [↑](#Commands) +find files (-type f) or directories (-type d) by name [↑](#Commands) ```bash -git log origin/master..HEAD +result=`find ./path -maxdepth ${2|0,1,2,3,4,5,6,7,8,9|} -type ${3|f,d|} -name "criteria"` ``` -## `git commit search` +## `if directory exists` -Search for a commit which contains searchCriteria. [↑](#Commands) +if directory exists [↑](#Commands) ```bash -git log --all --grep='searchCriteria' +if [ -d "$directory" ]; then + echo directory exists +fi ``` -## `git commit undo` +## `if file executable` -Undo last N commits (soft: preserve local changes | hard: delete local changes [↑](#Commands) +if file executable [↑](#Commands) ```bash -git reset --${1|soft,hard|} HEAD~${2|1,2,3,4,5|} +if [ -x "$file" ]; then + echo file is executable +fi ``` -## `git config list` +## `if file link` -List git configurations. [↑](#Commands) +if file exists and is a symbolic link [↑](#Commands) ```bash -git config --list +if [ -h "$file" ]; then + echo symbolic link +fi ``` -## `git config set` +## `if file exists` -Configure git. [↑](#Commands) +if file exists [↑](#Commands) ```bash -git config --${1|local,global|} ${2|user.name,user.email|} "value" +if [ -f "$file" ]; then + echo file exists +fi ``` -## `git patch apply` +## `if file not empty` -Apply a patch from file. [↑](#Commands) +if file size is greater than zero [↑](#Commands) ```bash -git apply < /path/to/patch1.patch +if [ -s "$file" ]; then + echo file not empty +fi ``` -## `git patch create` +## `if file readable` -Create a patch from changes. [↑](#Commands) +if file readable [↑](#Commands) ```bash -git diff > /path/to/patch1.patch +if [ -r "$file" ]; then + echo file is readable +fi ``` -## `git remote list` +## `if file writeable` -List all remotes. [↑](#Commands) +if file writeable [↑](#Commands) ```bash -git remote +if [ -w "$file" ]; then + echo file is writeable +fi ``` -## `git remote urlAdd` +## `if file newer` -Add remote url. [↑](#Commands) +if file1 newer than file2 [↑](#Commands) ```bash -git remote add origin https://github.com/user/repository.git +if [ "$file1" -nt "$file2" ]; then + echo file1 is newer than file2 +fi ``` -## `git remote urlChange` +## `if file older` -Change remote url. [↑](#Commands) +if file1 older than file2 [↑](#Commands) ```bash -git remote set-url origin https://github.com/user/repository.git +if [ "$file1" -ot "$file2" ]; then + echo file1 is older than file2 +fi ``` -## `git tag list` +## `if file =` -List all tags. [↑](#Commands) +if files are equal [↑](#Commands) ```bash -git tag +if [ "$file1" -ef "$file2" ]; then + echo files are equal +fi ``` -## `git tag commit,git commit tag` +## `if exists` -Tag a commit. [↑](#Commands) +if path exists (file, directory, link...) [↑](#Commands) ```bash -git tag -a release/1.0.0 -m "1.0.0 release" +if [ -e "$path" ]; then + echo exists +fi ``` -## `git tag remote delete` +## `remove files older` -Delete tag from remote. [↑](#Commands) +find and remove files older than x days [↑](#Commands) ```bash -git push --delete origin tagName && git push origin :tagName +find "$path" -mtime +days | xargs rm -f ``` -## `git tag remote push` +## `fn banner color` -Push tag to remote. [↑](#Commands) +print a color banner. [↑](#Commands) ```bash -git push origin tagName +# Usage: banner_color green "my title" +function banner_color() { + local color=$1 + shift + case $color in + black) color=0 + ;; + red) color=1 + ;; + green) color=2 + ;; + yellow) color=3 + ;; + blue) color=4 + ;; + magenta) color=5 + ;; + cyan) color=6 + ;; + white) color=7 + ;; + *) echo "color is not set"; exit 1 + ;; + esac + local s=("$@") b w + for l in "${s[@]}"; do + ((w<${#l})) && { b="$l"; w="${#l}"; } + done + tput setaf $color + echo " =${b//?/=}= +| ${b//?/ } |" + for l in "${s[@]}"; do + printf '| %s%*s%s |\n' "$(tput setaf $color)" "-$w" "$l" "$(tput setaf $color)" + done + echo "| ${b//?/ } | + =${b//?/=}=" + tput sgr 0 +} ``` -## `http GET,http DELETE` +## `fn banner simple` -Send http GET/DELETE request using curl [↑](#Commands) +function: print a banner with provided title [↑](#Commands) ```bash -curl --request ${1|GET,DELETE|} -sL \ - --user-agent '${2|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \ - --url 'http://example.com' +# Usage: banner_simple "my title" +function banner_simple() { + local msg="* $* *" + local edge=`echo "$msg" | sed 's/./*/g'` + echo "$edge" + echo "`tput bold`$msg`tput sgr0`" + echo "$edge" + echo +} ``` -## `http POST,http PUT` +## `fn import` -Send data with http POST/PUT, using curl [↑](#Commands) +import functions from other shellscript files [↑](#Commands) ```bash -curl --request ${1|POST,PUT|} -sL \ - --user-agent '${2|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \ - --url 'http://example.com' \ - --data 'key=${5:value}' \ - --data 'key=${7:value}' +# Usage: import "mylib" +function import() { + local file="./lib/$1.sh" + if [ -f "$file" ]; then + source "$file" + else + echo "Error: Cannot find library at: $file" + exit 1 + fi +} ``` -## `http POST file` +## `fn math average` -Send file with http POST, using curl [↑](#Commands) +Calculate average of given integers [↑](#Commands) ```bash -curl --request POST -sL \ - --user-agent '${1|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \ - --url 'http://example.com' \ - --form 'key=${4:value}' \ - --form 'file=@/path/to/file' +function average () { + local result=0 + for item in $@; do + ((result += item)) + done + echo $((result / $#)) +} ``` -## `http header` +## `fn math product` -Send http request with custom header, using curl [↑](#Commands) +Calculate product of given integers [↑](#Commands) ```bash -curl --request ${1|GET,POST,DELETE,PUT|} -sL \ - --user-agent '${2|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \ - --header 'key: ${4:value}' \ - --url 'http://example.com' +function product () { + local result=1 + for item in $@; do + ((result *= item)) + done + echo $result +} ``` -## `http cookie` +## `fn math sum` -Send http request with cookies, using curl [↑](#Commands) +Calculate sum of given integers [↑](#Commands) ```bash -curl --request ${1|GET,POST,DELETE,PUT|} -sL \ - --user-agent '${2|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \ - --cookie 'key=${4:value}' \ - --url 'http://example.com' +function sum () { + local result=0 + for item in $@; do + ((result += item)) + done + echo $result +} ``` -## `http download` +## `fn options` -Download from url and save to /path/to/file, using curl [↑](#Commands) +provide a list of options to user and return the index of selected option [↑](#Commands) ```bash -curl --request ${1|GET,POST|} -sL \ - --user-agent '${2|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \ - --output '/path/to/file' \ - --url 'http://example.com/file.zip' +# Usage: options=("one" "two" "three"); chooseOption "Choose:" 1 "${options[@]}"; choice=$?; echo "${options[$choice]}" +function chooseOption() { + echo "$1"; shift + echo `tput sitm``tput dim`-"Change selection: [up/down] Select: [ENTER]" `tput sgr0` + local selected="$1"; shift + ESC=`echo -e "\033"` + cursor_blink_on() { tput cnorm; } + cursor_blink_off() { tput civis; } + cursor_to() { tput cup $(($1-1)); } + print_option() { echo `tput dim` " $1" `tput sgr0`; } + print_selected() { echo `tput bold` "=> $1" `tput sgr0`; } + get_cursor_row() { IFS=';' read -sdR -p $'\E[6n' ROW COL; echo ${ROW#*[}; } + key_input() { read -s -n3 key 2>/dev/null >&2; [[ $key = $ESC[A ]] && echo up; [[ $key = $ESC[B ]] && echo down; [[ $key = "" ]] && echo enter; } + for opt; do echo; done + local lastrow=`get_cursor_row` + local startrow=$(($lastrow - $#)) + trap "cursor_blink_on; echo; echo; exit" 2 + cursor_blink_off + : selected:=0 + while true; do + local idx=0 + for opt; do + cursor_to $(($startrow + $idx)) + if [ $idx -eq $selected ]; then + print_selected "$opt" + else + print_option "$opt" + fi + ((idx++)) + done + case `key_input` in + enter) break;; + up) ((selected--)); [ $selected -lt 0 ] && selected=$(($# - 1));; + down) ((selected++)); [ $selected -ge $# ] && selected=0;; + esac + done + cursor_to $lastrow + cursor_blink_on + echo + return $selected +} ``` -## `ftp list` +## `fn progress` -Get the list of files on the ftp server at specific path [↑](#Commands) +progress bar function [↑](#Commands) ```bash -curl ftp://user:password@ipOrDomain/directoryPathOnServer/ +function progressBar() { + local BAR='████████████████████' + local SPACE=' ' + for i in {1..20}; do + echo -ne "\r|${BAR:0:$i}${SPACE:$i:20}| $(($i*5))% [ $2 ] " + sleep $1 + done + echo -ne '' +} ``` -## `ftp download` +## `fn scan` -Download specified file from ftp server [↑](#Commands) +Scan host's port range (tcp/udp) [↑](#Commands) ```bash -curl ftp://user:password@ipOrDomain/filePathOnServer/ +# Usage: scan proto host fromPort toPort +function scan () { + for ((port=$3; port<=$4; port++)); do + (echo >/dev/$1/$2/$port) >/dev/null 2>&1 && echo "$1 $port => open" + done +} ``` -## `ftp upload` +## `fn version compare,fn semver compare` -Upload specified file to ftp server [↑](#Commands) +function: compares two semvers and returns >, < or = [↑](#Commands) ```bash -curl -T fileToUpload ftp://user:password@ipOrDomain/directoryPathOnServer/ +# Usage: version_compare "1.2.3" "1.1.7" +function version_compare () { + function sub_ver () { + local len=${#1} + temp=${1%%"."*} && indexOf=`echo ${1%%"."*} | echo ${#temp}` + echo -e "0:indexOf" + } + function cut_dot () { + local offset=${#1} + local length=${#2} + echo -e "((++offset)):length" + } + if [ -z "$1" ] || [ -z "$2" ]; then + echo "=" && exit 0 + fi + local v1=`echo -e "${1}" | tr -d '[[:space:]]'` + local v2=`echo -e "${2}" | tr -d '[[:space:]]'` + local v1_sub=`sub_ver $v1` + local v2_sub=`sub_ver $v2` + if (( v1_sub > v2_sub )); then + echo ">" + elif (( v1_sub < v2_sub )); then + echo "<" + else + version_compare `cut_dot $v1_sub $v1` `cut_dot $v2_sub $v2` + fi +} ``` -## `ftp delete file` +## `fx banner color` -Delete specified file from ftp server [↑](#Commands) +call banner_color function [↑](#Commands) ```bash -curl ftp://user:password@ipOrDomain/path/fileToDelete -Q "DELE fileToDelete" +banner_color ${1|black,red,green,yellow,blue,magenta,cyan,white|} "my title" ``` -## `ftp rename` +## `fx banner simple` -Rename specified file/directory on ftp server [↑](#Commands) +call banner_simple function [↑](#Commands) ```bash -curl ftp://user:password@ipOrDomain/path/ -Q "-RNFR path/renameFrom" -Q "-RNTO path/renameTo" +banner_simple "my title" ``` -## `if` +## `fx import` -if [↑](#Commands) +call import function, to import functions from other shellscript files located in a directory (default: lib) relative to current script file [↑](#Commands) ```bash -if [ condition ]; then - # body -elif [ condition ]; then - # body -else - # body -fi +import "libname" ``` -## `iff` +## `fx math average` -if condition is true then run command (short circuit) [↑](#Commands) +Call math average function [↑](#Commands) ```bash -[ condition ] && command +result=`average $var1 $var2 $var3` ``` -## `iff not` +## `fx math product` -if condition is false then run command (short circuit) [↑](#Commands) +Call math product function [↑](#Commands) ```bash -[ condition ] || command +result=`product $var1 $var2 $var3` ``` -## `if string empty` +## `fx math sum` -if string is empty [↑](#Commands) +Call math sum function [↑](#Commands) ```bash -if [ -z "$string" ]; then - # body -fi +result=`sum $var1 $var2 $var3` ``` -## `if string not empty` +## `fx options` -if string is not empty [↑](#Commands) +call options function [↑](#Commands) ```bash -if [ -n "$string" ]; then - # body -fi +options=("one" "two" "three") +chooseOption "Choose:" 1 "${options[@]}"; choice=$? +echo "${options[$choice]}" selected ``` -## `if string =,string equal` +## `fx progress` -if strings are equal [↑](#Commands) +call progress bar function [↑](#Commands) ```bash -if [ "$string1" = "$string2" ]; then - # body -fi +progressBar ${1|.1,.2,.3,.4,.5,1,2,5|} "Installing foo..." ``` -## `if string !=,string not equal` +## `fx scan` -if strings are not equal [↑](#Commands) +call scan function to scan a host over a port range [↑](#Commands) ```bash -if [ "$string1" != "$string2" ]; then - # body -fi +scan ${1|tcp,udp|} host fromPort toPort ``` -## `string length` +## `fx version compare,fx semver compare` -length of string in characters [↑](#Commands) +call version_compare function [↑](#Commands) ```bash -length=${#variable} +version_compare "major.minor.patch" "major.minor.patch" ``` -## `string trim` +## `ftp delete file` -remove leading and trailing white space(s) [↑](#Commands) +Delete specified file from ftp server [↑](#Commands) ```bash -trimmed=`echo -e "${var}" | sed -e 's/^[[:space:]]*//' | sed -e 's/[[:space:]]*$//'` +curl ftp://user:password@ipOrDomain/path/fileToDelete -Q "DELE fileToDelete" ``` -## `string trim left` +## `ftp download` -remove leading white space(s) [↑](#Commands) +Download specified file from ftp server [↑](#Commands) ```bash -trimmed=`echo -e "${var}" | sed -e 's/^[[:space:]]*//'` +curl ftp://user:password@ipOrDomain/filePathOnServer/ ``` -## `string trim right` +## `ftp list` -remove trailing white space(s) [↑](#Commands) +Get the list of files on the ftp server at specific path [↑](#Commands) ```bash -trimmed=`echo -e "${var}" | sed -e 's/[[:space:]]*$//'` +curl ftp://user:password@ipOrDomain/directoryPathOnServer/ ``` -## `string trim all` +## `ftp rename` -remove all white space(s) [↑](#Commands) +Rename specified file/directory on ftp server [↑](#Commands) ```bash -trimmed=`echo -e "${var}" | tr -d '[[:space:]]'` +curl ftp://user:password@ipOrDomain/path/ -Q "-RNFR path/renameFrom" -Q "-RNTO path/renameTo" ``` -## `string replace` +## `ftp upload` -find all occurrences of a substrings and replace them [↑](#Commands) +Upload specified file to ftp server [↑](#Commands) ```bash -replaced=`echo -e "${var}" | sed -e 's/find/replace/g'` +curl -T fileToUpload ftp://user:password@ipOrDomain/directoryPathOnServer/ ``` -## `string reverse` +## `func args` -reverse string characters [↑](#Commands) +function arguments array [↑](#Commands) ```bash -reversed=`echo -e "${var}" | rev` +echo "$@" ``` -## `string toLower` +## `func args count` -convert string to lowercase [↑](#Commands) +number of function arguments [↑](#Commands) ```bash -toLower=`echo -e "${var}" | tr '[:upper:]' '[:lower:]'` +echo $# ``` -## `string toUpper` +## `func` -convert string to uppercase [↑](#Commands) +function [↑](#Commands) ```bash -toUpper=`echo -e "${var}" | tr '[:lower:]' '[:upper:]'` +function name () { + echo "$1" # arguments are accessible through $1, $2,... +} ``` -## `string substring` +## `func ret val` -part of the string from offset with length characters [↑](#Commands) +last function/command return code [↑](#Commands) ```bash -substring=`echo -e "${var:offset:length}"` +echo "$?" ``` -## `string contains,if string contains` +## `git branch create` -check whether string contains substring [↑](#Commands) +Create branch locally and switch into it. [↑](#Commands) ```bash -if [[ "$string" = *substring* ]]; then - # body -fi +git checkout -b branchName ``` -## `string substring count,string substring frequency` +## `git branch delete local` -Frequency of a substring in a string (may need character escaping) [↑](#Commands) +Delete local branch. [↑](#Commands) ```bash -frequency=`sed -E 's/(.)/\1\n/g' <<<"string" | grep -c "substring"` +git branch --delete localBranch ``` -## `string indexOf` +## `git branch delete remote` -first index of substring in string [↑](#Commands) +Delete remote branch. [↑](#Commands) ```bash -temp=${string%%"substring"*} && indexOf=`echo ${string%%"substring"*} | echo ${#temp}` -# echo $indexOf +git push origin --delete remoteBranch ``` -## `if int =` +## `git branch list` -if integers are equal [↑](#Commands) +List all branches. [↑](#Commands) ```bash -if (( int1 == ${2:int2} )); then - echo equal -fi +git branch ``` -## `if int !=` +## `git branch push` -if integers are not equal [↑](#Commands) +Push branch to remote. [↑](#Commands) ```bash -if (( int1 != ${2:int2} )); then - echo not equal -fi +git push origin branchName ``` -## `if int >` +## `git branch rename` -if integer greater than value [↑](#Commands) +Rename current branch. [↑](#Commands) ```bash -if (( int > ${2:val} )); then - echo greater -fi +git branch -m newName ``` -## `if int >=` +## `git changes revert` -if integer greater than or equal value [↑](#Commands) +Revert tracked changes [↑](#Commands) ```bash -if (( int >= ${2:val} )); then - echo greater equal -fi +git checkout . ``` -## `if int <` +## `git clone branch` -if integer lesser than value [↑](#Commands) +Clone a remote branch to local machine. [↑](#Commands) ```bash -if (( int < ${2:val} )); then - echo lesser -fi +git clone -b branchName https://github.com/user/repository.git ``` -## `if int <=` +## `git clone` -if integer lesser than or equal value [↑](#Commands) +Clone remote repository to local machine. [↑](#Commands) ```bash -if (( int <= ${2:val} )); then - echo lesser equal -fi +git clone https://github.com/user/repository.git ``` -## `if cmd exists` +## `git commit list notPushed` -check if command exists [↑](#Commands) +List non pushed commits. [↑](#Commands) ```bash -if [ `command -v command` ]; then - # body -fi +git log origin/master..HEAD ``` -## `if exists` +## `git commit search` -if path exists (file, directory, link...) [↑](#Commands) +Search for a commit which contains searchCriteria. [↑](#Commands) ```bash -if [ -e "$path" ]; then - echo exists -fi +git log --all --grep='searchCriteria' ``` -## `if file exists` +## `git commit undo` -if file exists [↑](#Commands) +Undo last N commits (soft: preserve local changes | hard: delete local changes [↑](#Commands) ```bash -if [ -f "$file" ]; then - echo file exists -fi +git reset --${1|soft,hard|} HEAD~${2|1,2,3,4,5|} ``` -## `if file not empty` +## `git commit` -if file size is greater than zero [↑](#Commands) +Commit changes. [↑](#Commands) ```bash -if [ -s "$file" ]; then - echo file not empty -fi +git commit -m "commit message" ``` -## `if directory exists` +## `git config list` -if directory exists [↑](#Commands) +List git configurations. [↑](#Commands) ```bash -if [ -d "$directory" ]; then - echo directory exists -fi +git config --list ``` -## `if file readable` +## `git config set` -if file readable [↑](#Commands) +Configure git. [↑](#Commands) ```bash -if [ -r "$file" ]; then - echo file is readable -fi +git config --${1|local,global|} ${2|user.name,user.email|} "value" ``` -## `if file writeable` +## `git patch apply` -if file writeable [↑](#Commands) +Apply a patch from file. [↑](#Commands) ```bash -if [ -w "$file" ]; then - echo file is writeable -fi +git apply < /path/to/patch1.patch ``` -## `if file executable` +## `git patch create` -if file executable [↑](#Commands) +Create a patch from changes. [↑](#Commands) ```bash -if [ -x "$file" ]; then - echo file is executable -fi +git diff > /path/to/patch1.patch ``` -## `if file =` +## `git remote list` -if files are equal [↑](#Commands) +List all remotes. [↑](#Commands) ```bash -if [ "$file1" -ef "$file2" ]; then - echo files are equal -fi +git remote ``` -## `if file link` +## `git remote urlChange` -if file exists and is a symbolic link [↑](#Commands) +Change remote url. [↑](#Commands) ```bash -if [ -h "$file" ]; then - echo symbolic link -fi +git remote set-url origin https://github.com/user/repository.git ``` -## `if file newer` +## `git remote urlAdd` -if file1 newer than file2 [↑](#Commands) +Add remote url. [↑](#Commands) ```bash -if [ "$file1" -nt "$file2" ]; then - echo file1 is newer than file2 -fi +git remote add origin https://github.com/user/repository.git ``` -## `if file older` +## `git tag commit,git commit tag` -if file1 older than file2 [↑](#Commands) +Tag a commit. [↑](#Commands) ```bash -if [ "$file1" -ot "$file2" ]; then - echo file1 is older than file2 -fi +git tag -a release/1.0.0 -m "1.0.0 release" ``` -## `ips` +## `git tag list` -Array of local IPs [↑](#Commands) +List all tags. [↑](#Commands) ```bash -IPS=`hostname -I` +git tag ``` -## `ip info` +## `git tag remote delete` -public ip information [↑](#Commands) +Delete tag from remote. [↑](#Commands) ```bash -echo `curl -s ipinfo.io/${1|ip,city,region,country,loc,postal,org|}` +git push --delete origin tagName && git push origin :tagName ``` -## `ip public` +## `git tag remote push` -public ip address [↑](#Commands) +Push tag to remote. [↑](#Commands) ```bash -PUBLIC_IP=`curl -s ${1|bot.whatismyipaddress.com,ident.me,ipecho.net/plain,icanhazip.com,ifconfig.me,api.ipify.org,ipinfo.io/ip|}` +git push origin tagName ``` -## `for i` +## `http cookie` -for loop by index [↑](#Commands) +Send http request with cookies, using curl [↑](#Commands) ```bash -for((i=0;i=` -arithmetic operations [↑](#Commands) +if integer greater than or equal value [↑](#Commands) ```bash -expr 2 ${2|+,-,\*,/,%|} 3 +if (( int >= ${2:val} )); then + echo greater equal +fi ``` -## `math ++` +## `if int >` -increment variable [↑](#Commands) +if integer greater than value [↑](#Commands) ```bash -((${1|var++,++var|})) +if (( int > ${2:val} )); then + echo greater +fi ``` -## `math --` +## `if int <=` -decrement variable [↑](#Commands) +if integer lesser than or equal value [↑](#Commands) ```bash -((${1|var--,--var|})) +if (( int <= ${2:val} )); then + echo lesser equal +fi ``` -## `math +` +## `if int <` -add two variables [↑](#Commands) +if integer lesser than value [↑](#Commands) ```bash -result=$((var1 + var2)) +if (( int < ${2:val} )); then + echo lesser +fi ``` -## `math +=` +## `if int !=` -add var1 and var2 and assign the result to var1 [↑](#Commands) +if integers are not equal [↑](#Commands) ```bash -((var1 += var2)) +if (( int1 != ${2:int2} )); then + echo not equal +fi ``` -## `math -` +## `ips` -subtract var2 from var1 [↑](#Commands) +Array of local IPs [↑](#Commands) ```bash -result=$((var1 - var2)) +IPS=`hostname -I` ``` -## `math -=` +## `ip info` -subtract var2 from var1 and assign the result to var1 [↑](#Commands) +public ip information [↑](#Commands) ```bash -((var1 -= var2)) +echo `curl -s ipinfo.io/${1|ip,city,region,country,loc,postal,org|}` ``` -## `math *` +## `ip public` -multiply var1 by var2 [↑](#Commands) +public ip address [↑](#Commands) ```bash -result=$((var1 * var2)) +PUBLIC_IP=`curl -s ${1|bot.whatismyipaddress.com,ident.me,ipecho.net/plain,icanhazip.com,ifconfig.me,api.ipify.org,ipinfo.io/ip|}` ``` -## `math *=` +## `for ij` -multiply var1 by var2 and assign the result to var1 [↑](#Commands) +for loop by index [↑](#Commands) ```bash -((var1 *= var2)) +for((i=0;i ${2:/path/to/file} -for line in ${lines}; do - echo "$line" >> /path/to/file -done +result=$((var1 / var2)) ``` -## `file write multiline` +## `math 0.00` -write multiple lines into file [↑](#Commands) +math operations with up to scale decimal places precision [↑](#Commands) ```bash -cat >filepath < 0 ]]; do + case "$1" in + -f|--flag) + echo flag: $1 + shift # shift once since flags have no values + ;; + -s|--switch) + echo switch $1 with value: $2 + shift 2 # shift twice to bypass switch and its value + ;; + *) # unknown flag/switch + POSITIONAL+=("$1") + shift + ;; + esac +done +set -- "${POSITIONAL[@]}" # restore positional params ``` -## `format reverse` +## `expr` -write in reverse [↑](#Commands) +arithmetic operations [↑](#Commands) ```bash -echo `tput rev`reversed text`tput sgr0` +expr 2 ${2|+,-,\*,/,%|} 3 ``` -## `process list` +## `let` -List processes [↑](#Commands) +arithmetic operations [↑](#Commands) ```bash -ps -A +let "result = var1 ${3|+,-,*,/,%|} var2" ``` -## `process ID` +## `region` -Find process id (PID) [↑](#Commands) +Comment out a special region (i.e. variable declarations [↑](#Commands) ```bash -pgrep process_name +# >>>>>>>>>>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>>>>>>>>>>> +$0 +# <<<<<<<<<<<<<<<<<<<<<<<< name <<<<<<<<<<<<<<<<<<<<<<<< ``` -## `process kill` +## `bash,shebang` -Kill process by name [↑](#Commands) +bash shebang [↑](#Commands) ```bash -sudo kill -9 `pgrep process_name` +#!/usr/bin/env ${1|bash,node,perl,php,python,python3,ruby|} ``` -## `region` +## `sleep` -Comment out a special region (i.e. variable declarations [↑](#Commands) +sleep for a specified amount of time (s: second, m: minute, h: hour, d: day) [↑](#Commands) ```bash -# >>>>>>>>>>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>>>>>>>>>>> -$0 -# <<<<<<<<<<<<<<<<<<<<<<<< name <<<<<<<<<<<<<<<<<<<<<<<< +sleep 30${2|s,m,h,d|} ``` -## `service manage` +## `stopwatch elapsed` -Manage service operations [↑](#Commands) +elapsed time [↑](#Commands) ```bash -sudo systemctl ${1|enable,disable,start,stop,reload,restart,status|} service +STOPWATCH_ELAPSED_TOTAL_SECONDS=$((STOPWATCH_END_TIME - STOPWATCH_START_TIME)) +STOPWATCH_ELAPSED_MINUTES=$((STOPWATCH_ELAPSED_TOTAL_SECONDS / 60)) +STOPWATCH_ELAPSED_SECONDS=$((STOPWATCH_ELAPSED_TOTAL_SECONDS % 60)) +echo elapsed $STOPWATCH_ELAPSED_MINUTES minutes and $STOPWATCH_ELAPSED_SECONDS seconds ``` ## `stopwatch start` @@ -1986,431 +2063,394 @@ stop stopwatch [↑](#Commands) STOPWATCH_END_TIME=$(date +%s) ``` -## `stopwatch elapsed` +## `summary` -elapsed time [↑](#Commands) +script summary [↑](#Commands) ```bash -STOPWATCH_ELAPSED_TOTAL_SECONDS=$((STOPWATCH_END_TIME - STOPWATCH_START_TIME)) -STOPWATCH_ELAPSED_MINUTES=$((STOPWATCH_ELAPSED_TOTAL_SECONDS / 60)) -STOPWATCH_ELAPSED_SECONDS=$((STOPWATCH_ELAPSED_TOTAL_SECONDS % 60)) -echo elapsed $STOPWATCH_ELAPSED_MINUTES minutes and $STOPWATCH_ELAPSED_SECONDS seconds +# Title: title +# Description: description +# Author: author +# Date: yyyy-mm-dd +# Version: 1.0.0 ``` -## `sleep` +## `timeout` -sleep for a specified amount of time (s: second, m: minute, h: hour, d: day) [↑](#Commands) +Run command within a time frame [↑](#Commands) ```bash -sleep 30${2|s,m,h,d|} +timeout seconds command ``` -## `system memory info` +## `assign if empty` -System memory information in kilobytes (KB) [↑](#Commands) +assign default to variable if variable is empty or null [↑](#Commands) ```bash -sysMemory${1|MemTotal,MemFree,MemAvailable,Cached,Buffers,Active,Inactive,SwapTotal,SwapFree,SwapCached|}=`cat /proc/meminfo | grep '${1}' | awk '{print $2}' | head -n 1` +: "${variable:=default}" ``` -## `system distro name` +## `color black` -OS ID (i.e. Ubuntu) [↑](#Commands) +write in black [↑](#Commands) ```bash -lsb_release -i | awk '{print $3}' +echo `tput setaf 0`black text`tput sgr0` ``` -## `system distro version` +## `color blue` -OS Release (i.e. 16.04) [↑](#Commands) +write in blue [↑](#Commands) ```bash -lsb_release -r | awk '{print $2}' +echo `tput setaf 4`blue text`tput sgr0` ``` -## `system distro codename` +## `color cyan` -OS codename (i.e. xenial) [↑](#Commands) +write in cyan [↑](#Commands) ```bash -lsb_release -c | awk '{print $2}' +echo `tput setaf 6`cyan text`tput sgr0` ``` -## `system kernel name` +## `color green` -OS kernel name (i.e. Linux) [↑](#Commands) +write in green [↑](#Commands) ```bash -uname -s +echo `tput setaf 2`green text`tput sgr0` ``` -## `system kernel release` +## `color magenta` -OS kernel release (i.e. 4.4.0-140-generic) [↑](#Commands) +write in magenta [↑](#Commands) ```bash -uname -r +echo `tput setaf 5`magenta text`tput sgr0` ``` -## `system processor type` +## `color red` -OS processor type (i.e. x86_64) [↑](#Commands) +write in red [↑](#Commands) ```bash -uname -p +echo `tput setaf 1`red text`tput sgr0` ``` -## `system processor count` +## `color white` -Processor count (cores) [↑](#Commands) +write in white [↑](#Commands) ```bash -lscpu | grep 'CPU(s)' |awk '{print $2}' | head -n 1 +echo `tput setaf 7`white text`tput sgr0` ``` -## `system processor architecture` +## `color yellow` -Processor architecture (i.e. x86_64) [↑](#Commands) +write in yellow [↑](#Commands) ```bash -lscpu | grep 'Architecture' |awk '{print $2}' | head -n 1 +echo `tput setaf 3`yellow text`tput sgr0` ``` -## `system processor model` +## `format bold` -Processor model name (i.e. Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz) [↑](#Commands) +write in bold [↑](#Commands) ```bash -lscpu | grep 'Model name' |cut -d ' ' -f 3- | sed -e 's/^[[:space:]]*//' +echo `tput bold`bold text`tput sgr0` ``` -## `system uptime` +## `format dim` -System uptime (hh:mm:ss) [↑](#Commands) +write in dim [↑](#Commands) ```bash -sys_uptime=`uptime | cut -d ' ' -f2` +echo `tput dim`dimmed text`tput sgr0` ``` -## `timeout` +## `format italic` -Run command within a time frame [↑](#Commands) +write in italic [↑](#Commands) ```bash -timeout seconds command +echo `tput sitm`italic text`tput sgr0` ``` -## `fn banner simple` +## `format reverse` -function: print a banner with provided title [↑](#Commands) +write in reverse [↑](#Commands) ```bash -# Usage: banner_simple "my title" -function banner_simple() { - local msg="* $* *" - local edge=`echo "$msg" | sed 's/./*/g'` - echo "$edge" - echo "`tput bold`$msg`tput sgr0`" - echo "$edge" - echo -} +echo `tput rev`reversed text`tput sgr0` ``` -## `fx banner simple` +## `string contains,if string contains` -call banner_simple function [↑](#Commands) +check whether string contains substring [↑](#Commands) ```bash -banner_simple "my title" +if [[ "$string" = *substring* ]]; then + # body +fi ``` -## `fn banner color` +## `string indexOf` -print a color banner. [↑](#Commands) +first index of substring in string [↑](#Commands) ```bash -# Usage: banner_color green "my title" -function banner_color() { - local color=$1 - shift - case $color in - black) color=0 - ;; - red) color=1 - ;; - green) color=2 - ;; - yellow) color=3 - ;; - blue) color=4 - ;; - magenta) color=5 - ;; - cyan) color=6 - ;; - white) color=7 - ;; - *) echo "color is not set"; exit 1 - ;; - esac - local s=("$@") b w - for l in "${s[@]}"; do - ((w<${#l})) && { b="$l"; w="${#l}"; } - done - tput setaf $color - echo " =${b//?/=}= -| ${b//?/ } |" - for l in "${s[@]}"; do - printf '| %s%*s%s |\n' "$(tput setaf $color)" "-$w" "$l" "$(tput setaf $color)" - done - echo "| ${b//?/ } | - =${b//?/=}=" - tput sgr 0 -} +temp=${string%%"substring"*} && indexOf=`echo ${string%%"substring"*} | echo ${#temp}` +# echo $indexOf ``` -## `fx banner color` +## `if string empty` -call banner_color function [↑](#Commands) +if string is empty [↑](#Commands) ```bash -banner_color ${1|black,red,green,yellow,blue,magenta,cyan,white|} "my title" +if [ -z "$string" ]; then + # body +fi ``` -## `fn import` +## `if string =,string equal` -import functions from other shellscript files [↑](#Commands) +if strings are equal [↑](#Commands) ```bash -# Usage: import "mylib" -function import() { - local file="./lib/$1.sh" - if [ -f "$file" ]; then - source "$file" - else - echo "Error: Cannot find library at: $file" - exit 1 - fi -} +if [ "$string1" = "$string2" ]; then + # body +fi ``` -## `fx import` +## `if string not empty` -call import function, to import functions from other shellscript files located in a directory (default: lib) relative to current script file [↑](#Commands) +if string is not empty [↑](#Commands) ```bash -import "libname" +if [ -n "$string" ]; then + # body +fi ``` -## `fn math sum` +## `if string !=,string not equal` -Calculate sum of given integers [↑](#Commands) +if strings are not equal [↑](#Commands) ```bash -function sum () { - local result=0 - for item in $@; do - ((result += item)) - done - echo $result -} +if [ "$string1" != "$string2" ]; then + # body +fi ``` -## `fx math sum` +## `string length` -Call math sum function [↑](#Commands) +length of string in characters [↑](#Commands) ```bash -result=`sum $var1 $var2 $var3` +length=${#variable} ``` -## `fn math product` +## `string replace` -Calculate product of given integers [↑](#Commands) +find all occurrences of a substrings and replace them [↑](#Commands) ```bash -function product () { - local result=1 - for item in $@; do - ((result *= item)) - done - echo $result -} +replaced=`echo -e "${var}" | sed -e 's/find/replace/g'` ``` -## `fx math product` +## `string reverse` -Call math product function [↑](#Commands) +reverse string characters [↑](#Commands) ```bash -result=`product $var1 $var2 $var3` +reversed=`echo -e "${var}" | rev` ``` -## `fn math average` +## `string substring count,string substring frequency` -Calculate average of given integers [↑](#Commands) +Frequency of a substring in a string (may need character escaping) [↑](#Commands) ```bash -function average () { - local result=0 - for item in $@; do - ((result += item)) - done - echo $((result / $#)) -} +frequency=`sed -E 's/(.)/\1\n/g' <<<"string" | grep -c "substring"` ``` -## `fx math average` +## `string substring` -Call math average function [↑](#Commands) +part of the string from offset with length characters [↑](#Commands) ```bash -result=`average $var1 $var2 $var3` +substring=`echo -e "${var:offset:length}"` ``` -## `fn options` +## `string toLower` -provide a list of options to user and return the index of selected option [↑](#Commands) +convert string to lowercase [↑](#Commands) ```bash -# Usage: options=("one" "two" "three"); chooseOption "Choose:" 1 "${options[@]}"; choice=$?; echo "${options[$choice]}" -function chooseOption() { - echo "$1"; shift - echo `tput sitm``tput dim`-"Change selection: [up/down] Select: [ENTER]" `tput sgr0` - local selected="$1"; shift - ESC=`echo -e "\033"` - cursor_blink_on() { tput cnorm; } - cursor_blink_off() { tput civis; } - cursor_to() { tput cup $(($1-1)); } - print_option() { echo `tput dim` " $1" `tput sgr0`; } - print_selected() { echo `tput bold` "=> $1" `tput sgr0`; } - get_cursor_row() { IFS=';' read -sdR -p $'\E[6n' ROW COL; echo ${ROW#*[}; } - key_input() { read -s -n3 key 2>/dev/null >&2; [[ $key = $ESC[A ]] && echo up; [[ $key = $ESC[B ]] && echo down; [[ $key = "" ]] && echo enter; } - for opt; do echo; done - local lastrow=`get_cursor_row` - local startrow=$(($lastrow - $#)) - trap "cursor_blink_on; echo; echo; exit" 2 - cursor_blink_off - : selected:=0 - while true; do - local idx=0 - for opt; do - cursor_to $(($startrow + $idx)) - if [ $idx -eq $selected ]; then - print_selected "$opt" - else - print_option "$opt" - fi - ((idx++)) - done - case `key_input` in - enter) break;; - up) ((selected--)); [ $selected -lt 0 ] && selected=$(($# - 1));; - down) ((selected++)); [ $selected -ge $# ] && selected=0;; - esac - done - cursor_to $lastrow - cursor_blink_on - echo - return $selected -} +toLower=`echo -e "${var}" | tr '[:upper:]' '[:lower:]'` ``` -## `fx options` +## `string toUpper` -call options function [↑](#Commands) +convert string to uppercase [↑](#Commands) ```bash -options=("one" "two" "three") -chooseOption "Choose:" 1 "${options[@]}"; choice=$? -echo "${options[$choice]}" selected +toUpper=`echo -e "${var}" | tr '[:lower:]' '[:upper:]'` ``` -## `fn progress` +## `string trim all` -progress bar function [↑](#Commands) +remove all white space(s) [↑](#Commands) ```bash -function progressBar() { - local BAR='████████████████████' - local SPACE=' ' - for i in {1..20}; do - echo -ne "\r|${BAR:0:$i}${SPACE:$i:20}| $(($i*5))% [ $2 ] " - sleep $1 - done - echo -ne '' -} +trimmed=`echo -e "${var}" | tr -d '[[:space:]]'` ``` -## `fx progress` +## `string trim left` -call progress bar function [↑](#Commands) +remove leading white space(s) [↑](#Commands) ```bash -progressBar ${1|.1,.2,.3,.4,.5,1,2,5|} "Installing foo..." +trimmed=`echo -e "${var}" | sed -e 's/^[[:space:]]*//'` ``` -## `fn scan` +## `string trim right` -Scan host's port range (tcp/udp) [↑](#Commands) +remove trailing white space(s) [↑](#Commands) ```bash -# Usage: scan proto host fromPort toPort -function scan () { - for ((port=$3; port<=$4; port++)); do - (echo >/dev/$1/$2/$port) >/dev/null 2>&1 && echo "$1 $port => open" - done -} +trimmed=`echo -e "${var}" | sed -e 's/[[:space:]]*$//'` ``` -## `fx scan` +## `string trim` -call scan function to scan a host over a port range [↑](#Commands) +remove leading and trailing white space(s) [↑](#Commands) ```bash -scan ${1|tcp,udp|} host fromPort toPort +trimmed=`echo -e "${var}" | sed -e 's/^[[:space:]]*//' | sed -e 's/[[:space:]]*$//'` ``` -## `fn version compare,fn semver compare` +## `system distro codename` -function: compares two semvers and returns >, < or = [↑](#Commands) +OS codename (i.e. xenial) [↑](#Commands) ```bash -# Usage: version_compare "1.2.3" "1.1.7" -function version_compare () { - function sub_ver () { - local len=${#1} - temp=${1%%"."*} && indexOf=`echo ${1%%"."*} | echo ${#temp}` - echo -e "0:indexOf" - } - function cut_dot () { - local offset=${#1} - local length=${#2} - echo -e "((++offset)):length" - } - if [ -z "$1" ] || [ -z "$2" ]; then - echo "=" && exit 0 - fi - local v1=`echo -e "${1}" | tr -d '[[:space:]]'` - local v2=`echo -e "${2}" | tr -d '[[:space:]]'` - local v1_sub=`sub_ver $v1` - local v2_sub=`sub_ver $v2` - if (( v1_sub > v2_sub )); then - echo ">" - elif (( v1_sub < v2_sub )); then - echo "<" - else - version_compare `cut_dot $v1_sub $v1` `cut_dot $v2_sub $v2` - fi -} +lsb_release -c | awk '{print $2}' ``` -## `fx version compare,fx semver compare` +## `system distro name` -call version_compare function [↑](#Commands) +OS ID (i.e. Ubuntu) [↑](#Commands) ```bash -version_compare "major.minor.patch" "major.minor.patch" +lsb_release -i | awk '{print $3}' +``` + +## `system distro version` + +OS Release (i.e. 16.04) [↑](#Commands) + +```bash +lsb_release -r | awk '{print $2}' +``` + +## `system kernel name` + +OS kernel name (i.e. Linux) [↑](#Commands) + +```bash +uname -s +``` + +## `system kernel release` + +OS kernel release (i.e. 4.4.0-140-generic) [↑](#Commands) + +```bash +uname -r +``` + +## `system memory info` + +System memory information in kilobytes (KB) [↑](#Commands) + +```bash +sysMemory${1|MemTotal,MemFree,MemAvailable,Cached,Buffers,Active,Inactive,SwapTotal,SwapFree,SwapCached|}=`cat /proc/meminfo | grep '${1}' | awk '{print $2}' | head -n 1` +``` + +## `process ID` + +Find process id (PID) [↑](#Commands) + +```bash +pgrep process_name +``` + +## `process kill` + +Kill process by name [↑](#Commands) + +```bash +sudo kill -9 `pgrep process_name` +``` + +## `process list` + +List processes [↑](#Commands) + +```bash +ps -A +``` + +## `system processor architecture` + +Processor architecture (i.e. x86_64) [↑](#Commands) + +```bash +lscpu | grep 'Architecture' |awk '{print $2}' | head -n 1 +``` + +## `system processor count` + +Processor count (cores) [↑](#Commands) + +```bash +lscpu | grep 'CPU(s)' |awk '{print $2}' | head -n 1 +``` + +## `system processor model` + +Processor model name (i.e. Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz) [↑](#Commands) + +```bash +lscpu | grep 'Model name' |cut -d ' ' -f 3- | sed -e 's/^[[:space:]]*//' +``` + +## `system processor type` + +OS processor type (i.e. x86_64) [↑](#Commands) + +```bash +uname -p +``` + +## `service manage` + +Manage service operations [↑](#Commands) + +```bash +sudo systemctl ${1|enable,disable,start,stop,reload,restart,status|} service +``` + +## `system uptime` + +System uptime (hh:mm:ss) [↑](#Commands) + +```bash +sys_uptime=`uptime | cut -d ' ' -f2` ``` diff --git a/build.js b/build.js new file mode 100644 index 0000000..d407764 --- /dev/null +++ b/build.js @@ -0,0 +1,116 @@ +const fs = require('fs') +const path = require('path') + +// pipe :: [Function] -> Function +const pipe = (...fns) => x => fns.reduce((v, f) => f(v), x) + +// directoryFiles :: String -> [String] +function directoryFiles(dir, result = []) { + fs.readdirSync(dir).forEach(item => + fs.statSync(path.join(dir, item)).isDirectory() ? + directoryFiles(path.join(dir, item), result) + : result.push(path.join(dir, item))) + return result +} + +// objectToString :: Object -> String +const objectToString = o => JSON.stringify(o, null, 2) + +// jsonFiles :: [String] -> [String] +const jsonFiles = filesArray => filesArray + .filter(f => f.trim().toLowerCase().slice(-5) === '.json') + +// filesContent :: [String] -> [[String, Object]] +const filesContent = files => files.map(f => { + try { + return { + key: path.parse(f).dir.split('/')[1] + '.' + path.parse(f).name, + value: JSON.parse(fs.readFileSync(f, 'utf-8')) + } + } catch (err) { + throw Error(`Cannot process json file: ${f}\nError: ${err}`) + } +}) + +// arrayToObject :: [[String, Object]] -> Object +const arrayToObject = arrayOfObjects => arrayOfObjects.reduce((acc, c) => { + acc[c.key] = c.value + return acc +}, {}) + +// write :: String -> IO +const write = str => fs.writeFileSync(path.join('snippets', 'snippets.json'), str) + +const app = pipe( + directoryFiles, + jsonFiles, + filesContent, + arrayToObject, + objectToString, + write +) + +// TODO: Refactoring +function docGen() { + const rgx = /\$\{\d+:(.*?)\}/g + const snippets = JSON.parse(fs.readFileSync( + path.join(__dirname, './snippets/snippets.json'), 'utf-8' + )) + + let out = '# Commands\n\n' + let ns = '' + + for (let snippetName in snippets) { // Table of Contents + const snippet = snippets[snippetName] + if (snippetName.split('.')[0] !== ns) { + ns = snippetName.split('.')[0] + out += `- ${ns}\n\n` + } + if (Array.isArray(snippet.prefix)) { + out += ` - [${snippet.prefix[0]}](#${snippet.prefix[0].split(' ').join('-')})\n\n` + } else { + out += ` - [${snippet.prefix}](#${snippet.prefix.split(' ').join('-')})\n\n` + } + } + + for (let snippetName in snippets) { + const snippet = snippets[snippetName] + out += `## \`${snippet.prefix}\`\n\n` + out += `${snippet.description} [↑](#Commands)\n\n` + out += '```bash\n' + let body = '' + let y + if (snippet.body.constructor === Array) { + let tmp = snippet.body.map(line => line.split('\n').join('')) + tmp = tmp.map(line => line.split('\t').join(' ')) + tmp = tmp.map(line => unescape(line).split('\\$').join('$')) + tmp = tmp.map((line) => { + let y + while ((y = rgx.exec(line)) !== null) { + line = line.split(y[0]).join(y[1]) + } + return line + }) + body = tmp.join('\n') + } else { // single line body + body = unescape(snippet.body) + body = body.split('\n').join('') + while ((y = rgx.exec(snippet.body)) !== null) { + body = body.split(y[0]).join(y[1]) + } + } + out += body + out += '\n```\n\n' + } + + // Replacing \$ with $s + out = out.replace(/\\\$/mg, '$') + + fs.writeFileSync(path.join(__dirname, 'COMMANDS.md'), out) +} + +// Entry Point +app('./nsroot') + +// Generate Documentation +docGen() diff --git a/docgen.js b/docgen.js deleted file mode 100644 index 51fcf22..0000000 --- a/docgen.js +++ /dev/null @@ -1,47 +0,0 @@ -const fs = require('fs') -const path = require('path') -const rgx = /\$\{\d+:(.*?)\}/g - -const snippets = JSON.parse(fs.readFileSync(path.join(__dirname, './snippets/snippets.json')).toString()) - -let out = '# Commands\n\n' - -for (let snippetName in snippets) { // ToC - if (Array.isArray(snippets[snippetName].prefix)) { - out += `- [${snippets[snippetName].prefix[0]}](#${snippets[snippetName].prefix[0].split(' ').join('-')})\n\n` - } else { - out += `- [${snippets[snippetName].prefix}](#${snippets[snippetName].prefix.split(' ').join('-')})\n\n` - } -} - -for (let snippetName in snippets) { - const snippet = snippets[snippetName] - out += `## \`${snippet.prefix}\`\n\n` - out += `${snippet.description} [↑](#Commands)\n\n` - out += '```bash\n' - let body = '' - let y - if (snippet.body.constructor === Array) { - let tmp = snippet.body.map(line => line.split('\n').join('')) - tmp = tmp.map(line => line.split('\t').join(' ')) - tmp = tmp.map(line => unescape(line).split('\\$').join('$')) - tmp = tmp.map((line) => { - let y - while ((y = rgx.exec(line)) !== null) { - line = line.split(y[0]).join(y[1]) - } - return line - }) - body = tmp.join('\n') - } else { // single line body - body = unescape(snippet.body) - body = body.split('\n').join('') - while ((y = rgx.exec(snippet.body)) !== null) { - body = body.split(y[0]).join(y[1]) - } - } - out += body - out += '\n```\n\n' -} - -fs.writeFileSync(path.join(__dirname, 'COMMANDS.md'), out) diff --git a/nsroot/README.md b/nsroot/README.md new file mode 100644 index 0000000..34c6803 --- /dev/null +++ b/nsroot/README.md @@ -0,0 +1,4 @@ +# Namespaces + +- Directory structure depth is fixed to one +- Don't use dot (`.`) in file names \ No newline at end of file diff --git a/nsroot/archive/compress-tar-gz.json b/nsroot/archive/compress-tar-gz.json new file mode 100644 index 0000000..10bcf72 --- /dev/null +++ b/nsroot/archive/compress-tar-gz.json @@ -0,0 +1,5 @@ +{ + "prefix": "archive compress tar.gz", + "body": "tar -czvf ${1:/path/to/archive}.tar.gz ${2:/path/to/directory-or-file}\n", + "description": "compress file/folder to a .tar.gz file" + } \ No newline at end of file diff --git a/nsroot/archive/decompress-tar-gz.json b/nsroot/archive/decompress-tar-gz.json new file mode 100644 index 0000000..aaa7c39 --- /dev/null +++ b/nsroot/archive/decompress-tar-gz.json @@ -0,0 +1,5 @@ +{ + "prefix": "archive decompress tar.gz", + "body": "tar -C ${1:/extract/to/path} -xzvf ${2:/path/to/archive}.tar.gz\n", + "description": "decompress a .tar.gz file to specified path" +} \ No newline at end of file diff --git a/nsroot/array/all-elements.json b/nsroot/array/all-elements.json new file mode 100644 index 0000000..e205146 --- /dev/null +++ b/nsroot/array/all-elements.json @@ -0,0 +1,5 @@ +{ + "prefix": "array all", + "body": "${myArray[@]}\n", + "description": "all array elements" +} \ No newline at end of file diff --git a/nsroot/array/at-index.json b/nsroot/array/at-index.json new file mode 100644 index 0000000..4800ecf --- /dev/null +++ b/nsroot/array/at-index.json @@ -0,0 +1,5 @@ +{ + "prefix": "array at index", + "body": "${myArray[${1:index}]}\n", + "description": "retrieve element at specified index (zero based)" +} \ No newline at end of file diff --git a/nsroot/array/concat.json b/nsroot/array/concat.json new file mode 100644 index 0000000..1d212b4 --- /dev/null +++ b/nsroot/array/concat.json @@ -0,0 +1,5 @@ +{ + "prefix": "array concat", + "body": "${1:newArray}=(\"${${2:array1}[@]}\" \"${${3:array2}[@]}\")\n", + "description": "concatenate two arrays" +} \ No newline at end of file diff --git a/nsroot/array/declare.json b/nsroot/array/declare.json new file mode 100644 index 0000000..5c34a2f --- /dev/null +++ b/nsroot/array/declare.json @@ -0,0 +1,5 @@ +{ + "prefix": "array declare", + "body": "${1:myArray}=('${2:one}' '${3:two}' '${4:three}')\n", + "description": "declare an array" +} \ No newline at end of file diff --git a/nsroot/array/delete-at.json b/nsroot/array/delete-at.json new file mode 100644 index 0000000..4f2c4e7 --- /dev/null +++ b/nsroot/array/delete-at.json @@ -0,0 +1,5 @@ +{ + "prefix": "array delete at", + "body": "unset ${1:myArray}[${2:index}]\n", + "description": "delete element at index from array" +} \ No newline at end of file diff --git a/nsroot/array/delete.json b/nsroot/array/delete.json new file mode 100644 index 0000000..bb0a8a1 --- /dev/null +++ b/nsroot/array/delete.json @@ -0,0 +1,5 @@ +{ + "prefix": "array delete", + "body": "unset ${1:myArray}\n", + "description": "delete entire array" +} \ No newline at end of file diff --git a/nsroot/array/filter.json b/nsroot/array/filter.json new file mode 100644 index 0000000..caa3b11 --- /dev/null +++ b/nsroot/array/filter.json @@ -0,0 +1,5 @@ +{ + "prefix": "array filter", + "body": "${1:filtered}=(`for i in ${${2:myArray}[@]} ; do echo \\$i; done | grep ${3:pattern}`)\n", + "description": "filter elements of an array based on given pattern" +} \ No newline at end of file diff --git a/nsroot/array/iterate.json b/nsroot/array/iterate.json new file mode 100644 index 0000000..4f1985d --- /dev/null +++ b/nsroot/array/iterate.json @@ -0,0 +1,12 @@ +{ + "prefix": [ + "array iterate", + "array forEach" + ], + "body": [ + "for item in ${${1:myArray}[@]}; do", + "\t${2:echo \"\\$item\"}", + "done\n" + ], + "description": "iterate array elements" +} \ No newline at end of file diff --git a/nsroot/array/length.json b/nsroot/array/length.json new file mode 100644 index 0000000..4e00781 --- /dev/null +++ b/nsroot/array/length.json @@ -0,0 +1,5 @@ +{ + "prefix": "array length", + "body": "${#${1:myArray}[@]}\n", + "description": "length of array" +} \ No newline at end of file diff --git a/nsroot/array/push.json b/nsroot/array/push.json new file mode 100644 index 0000000..9693ab1 --- /dev/null +++ b/nsroot/array/push.json @@ -0,0 +1,8 @@ +{ + "prefix": [ + "array push", + "array add" + ], + "body": "${1:myArray}+=('${2:newItem}')\n", + "description": "push new item to the end of array" +} \ No newline at end of file diff --git a/nsroot/array/range.json b/nsroot/array/range.json new file mode 100644 index 0000000..9f74176 --- /dev/null +++ b/nsroot/array/range.json @@ -0,0 +1,8 @@ +{ + "prefix": [ + "array slice", + "array range" + ], + "body": "${myArray[@]:${1:from}:${2:count}}\n", + "description": "elements of array from index, equal to count numbers" +} \ No newline at end of file diff --git a/nsroot/array/replace.json b/nsroot/array/replace.json new file mode 100644 index 0000000..3dfacc1 --- /dev/null +++ b/nsroot/array/replace.json @@ -0,0 +1,5 @@ +{ + "prefix": "array replace", + "body": "${myArray[@]//${1:find}/${2:replace}}\n", + "description": "find and replace elements in array using regex" +} \ No newline at end of file diff --git a/nsroot/array/set-element-at.json b/nsroot/array/set-element-at.json new file mode 100644 index 0000000..64aeeab --- /dev/null +++ b/nsroot/array/set-element-at.json @@ -0,0 +1,5 @@ +{ + "prefix": "array set element", + "body": "myArray[${1:index}]=${2:value}\n", + "description": "set array element at index" +} \ No newline at end of file diff --git a/nsroot/command/failure-check.json b/nsroot/command/failure-check.json new file mode 100644 index 0000000..ac786e6 --- /dev/null +++ b/nsroot/command/failure-check.json @@ -0,0 +1,9 @@ +{ + "prefix": "cmd failure check", + "body": [ + "if [[ \\$? != 0 ]]; then", + "\t${3:echo command failed}", + "fi\n" + ], + "description": "check if last command failed" +} \ No newline at end of file diff --git a/nsroot/command/if-exists.json b/nsroot/command/if-exists.json new file mode 100644 index 0000000..841c261 --- /dev/null +++ b/nsroot/command/if-exists.json @@ -0,0 +1,9 @@ +{ + "prefix": "if cmd exists", + "body": [ + "if [ `command -v ${1:command}` ]; then", + "\t${2:# body}", + "fi\n" + ], + "description": "check if command exists" +} \ No newline at end of file diff --git a/nsroot/command/nice.json b/nsroot/command/nice.json new file mode 100644 index 0000000..422ce08 --- /dev/null +++ b/nsroot/command/nice.json @@ -0,0 +1,5 @@ +{ + "prefix": "cmd nice", + "body": "sudo nice -n ${1|-20,-15,-10,-5,0,5,10,15,19|} ${0:command}\n", + "description": "run command with desired privilege. n: -20 (highest priority) to 19 (lowest priority)" +} \ No newline at end of file diff --git a/nsroot/command/renice.json b/nsroot/command/renice.json new file mode 100644 index 0000000..30dd14b --- /dev/null +++ b/nsroot/command/renice.json @@ -0,0 +1,5 @@ +{ + "prefix": "cmd renice", + "body": "for p in \\$(pidof \"${process_name}\"); do sudo renice -n ${1|-20,-15,-10,-5,0,5,10,15,19|} -p \\$p; done", + "description": "Change running process priority. n: -20 (highest priority) to 19 (lowest priority)" +} \ No newline at end of file diff --git a/nsroot/command/run.json b/nsroot/command/run.json new file mode 100644 index 0000000..c164f2d --- /dev/null +++ b/nsroot/command/run.json @@ -0,0 +1,5 @@ +{ + "prefix": "cmd", + "body": "$(${1:command})\n", + "description": "run command (command substitution)" +} \ No newline at end of file diff --git a/nsroot/command/success-check.json b/nsroot/command/success-check.json new file mode 100644 index 0000000..7e1d520 --- /dev/null +++ b/nsroot/command/success-check.json @@ -0,0 +1,9 @@ +{ + "prefix": "cmd success check", + "body": [ + "if [[ \\$? == 0 ]]; then", + "\t${3:echo command succeed}", + "fi\n" + ], + "description": "check if last command succeed" +} \ No newline at end of file diff --git a/nsroot/cryptography/base64-decode.json b/nsroot/cryptography/base64-decode.json new file mode 100644 index 0000000..2e9557b --- /dev/null +++ b/nsroot/cryptography/base64-decode.json @@ -0,0 +1,5 @@ +{ + "prefix": "crypto base64 decode", + "body": "${1:base64Decoded}=`echo -n \"\\$${2:variableToDecode}\" | base64 -d`\n", + "description": "decode variable from base64" +} \ No newline at end of file diff --git a/nsroot/cryptography/base64-encode.json b/nsroot/cryptography/base64-encode.json new file mode 100644 index 0000000..4108170 --- /dev/null +++ b/nsroot/cryptography/base64-encode.json @@ -0,0 +1,5 @@ +{ + "prefix": "crypto base64 encode", + "body": "${1:base64Encoded}=`echo -n \"\\$${2:variableToEncode}\" | base64`\n", + "description": "encode variable to base64" +} \ No newline at end of file diff --git a/nsroot/cryptography/hash.json b/nsroot/cryptography/hash.json new file mode 100644 index 0000000..227e1c1 --- /dev/null +++ b/nsroot/cryptography/hash.json @@ -0,0 +1,5 @@ +{ + "prefix": "crypto hash", + "body": "${1:hash}=`echo -n \"\\$${2:variableToHash}\" | ${3|md5sum,shasum,sha1sum,sha224sum,sha256sum,sha384sum,sha512sum|} | cut -f1 -d ' '`\n", + "description": "compute hash of variable (md5, sha, sha1, sha224, sha256, sha384, sha512)" +} \ No newline at end of file diff --git a/nsroot/date-time/day-of-month-current.json b/nsroot/date-time/day-of-month-current.json new file mode 100644 index 0000000..e24a4f8 --- /dev/null +++ b/nsroot/date-time/day-of-month-current.json @@ -0,0 +1,5 @@ +{ + "prefix": "date now dayOfMonth", + "body": "dayOfMonth=`date +%d`\n", + "description": "current day of month (1..31)" +} \ No newline at end of file diff --git a/nsroot/date-time/day-of-week-current.json b/nsroot/date-time/day-of-week-current.json new file mode 100644 index 0000000..fb0cda1 --- /dev/null +++ b/nsroot/date-time/day-of-week-current.json @@ -0,0 +1,5 @@ +{ + "prefix": "date now dayOfWeek", + "body": "dayOfWeek=`date +%${1|A,a|}`\n", + "description": "current day of week name (full/abbreviated A/a)" +} \ No newline at end of file diff --git a/nsroot/date-time/day-of-year-current.json b/nsroot/date-time/day-of-year-current.json new file mode 100644 index 0000000..c03499f --- /dev/null +++ b/nsroot/date-time/day-of-year-current.json @@ -0,0 +1,5 @@ +{ + "prefix": "date now dayOfYear", + "body": "dayOfYear=`date +%j`\n", + "description": "current day of year (1..366)" +} \ No newline at end of file diff --git a/nsroot/date-time/epoch-seconds.json b/nsroot/date-time/epoch-seconds.json new file mode 100644 index 0000000..9e590a5 --- /dev/null +++ b/nsroot/date-time/epoch-seconds.json @@ -0,0 +1,5 @@ +{ + "prefix": "time seconds epoch", + "body": "timeNowSecondsEpoch=`date +%s`\n", + "description": "seconds since epoch (1970-01-01 00:00:00)" +} \ No newline at end of file diff --git a/nsroot/date-time/local-time-current.json b/nsroot/date-time/local-time-current.json new file mode 100644 index 0000000..11eb8c8 --- /dev/null +++ b/nsroot/date-time/local-time-current.json @@ -0,0 +1,5 @@ +{ + "prefix": "time now local", + "body": "timeNowLocal=`date +%${1|R,r|}`\n", + "description": "current local time (24hrs/12hrs R/r)" +} \ No newline at end of file diff --git a/nsroot/date-time/month-name-current.json b/nsroot/date-time/month-name-current.json new file mode 100644 index 0000000..18d22f1 --- /dev/null +++ b/nsroot/date-time/month-name-current.json @@ -0,0 +1,5 @@ +{ + "prefix": "date now monthName", + "body": "monthName=`date +%${1|B,b|}`\n", + "description": "current month name (full/abbreviated B/b)" +} \ No newline at end of file diff --git a/nsroot/date-time/month-number-current.json b/nsroot/date-time/month-number-current.json new file mode 100644 index 0000000..8559612 --- /dev/null +++ b/nsroot/date-time/month-number-current.json @@ -0,0 +1,5 @@ +{ + "prefix": "date now monthNumber", + "body": "monthNumber=`date +%m`\n", + "description": "current month number (1..12)" +} \ No newline at end of file diff --git a/nsroot/date-time/short.json b/nsroot/date-time/short.json new file mode 100644 index 0000000..612128e --- /dev/null +++ b/nsroot/date-time/short.json @@ -0,0 +1,5 @@ +{ + "prefix": "date now short", + "body": "dateShort=`date -I`\n", + "description": "yyyy/mm/dd" +} \ No newline at end of file diff --git a/nsroot/date-time/time-utc.json b/nsroot/date-time/time-utc.json new file mode 100644 index 0000000..84bf89a --- /dev/null +++ b/nsroot/date-time/time-utc.json @@ -0,0 +1,5 @@ +{ + "prefix": "time now UTC", + "body": "timeNowUTC=`date -u +%R`\n", + "description": "current UTC time" +} \ No newline at end of file diff --git a/nsroot/date-time/utc.json b/nsroot/date-time/utc.json new file mode 100644 index 0000000..790b412 --- /dev/null +++ b/nsroot/date-time/utc.json @@ -0,0 +1,5 @@ +{ + "prefix": "date now UTC", + "body": "dateUTC=`date -u`\n", + "description": "coordinated Universal Time" +} \ No newline at end of file diff --git a/nsroot/date-time/year-current.json b/nsroot/date-time/year-current.json new file mode 100644 index 0000000..37f046e --- /dev/null +++ b/nsroot/date-time/year-current.json @@ -0,0 +1,5 @@ +{ + "prefix": "date now year", + "body": "year=`date +%Y`\n", + "description": "current Year" +} \ No newline at end of file diff --git a/nsroot/filesystem/directory-create-nested.json b/nsroot/filesystem/directory-create-nested.json new file mode 100644 index 0000000..0caced9 --- /dev/null +++ b/nsroot/filesystem/directory-create-nested.json @@ -0,0 +1,5 @@ +{ + "prefix": "directory create nested", + "body": "mkdir -p \"${1:parent dir}\"/\"${2:child dir}\"\n", + "description": "create nested directories" +} \ No newline at end of file diff --git a/nsroot/filesystem/directory-create.json b/nsroot/filesystem/directory-create.json new file mode 100644 index 0000000..8581e4f --- /dev/null +++ b/nsroot/filesystem/directory-create.json @@ -0,0 +1,5 @@ +{ + "prefix": "directory create", + "body": "mkdir \"${1:dirname}\"\n", + "description": "create directory" +} \ No newline at end of file diff --git a/nsroot/filesystem/file-delete.json b/nsroot/filesystem/file-delete.json new file mode 100644 index 0000000..e25a4f8 --- /dev/null +++ b/nsroot/filesystem/file-delete.json @@ -0,0 +1,8 @@ +{ + "prefix": [ + "file delete", + "file remove" + ], + "body": "rm -f ${1:./path/file}\n", + "description": "delete file(s)" +} \ No newline at end of file diff --git a/nsroot/filesystem/file-read.json b/nsroot/filesystem/file-read.json new file mode 100644 index 0000000..385eb63 --- /dev/null +++ b/nsroot/filesystem/file-read.json @@ -0,0 +1,9 @@ +{ + "prefix": "file read", + "body": [ + "cat ${1:\"\\$filepath\"} | while read ${2:line}; do", + "\t${3:echo \"\\$line\"}", + "done\n" + ], + "description": "read a file" +} \ No newline at end of file diff --git a/nsroot/filesystem/file-search.json b/nsroot/filesystem/file-search.json new file mode 100644 index 0000000..ebe8a5c --- /dev/null +++ b/nsroot/filesystem/file-search.json @@ -0,0 +1,9 @@ +{ + "prefix": [ + "file search", + "search in files", + "find in files" + ], + "body": "result=`find ${1:./path} -maxdepth ${2|0,1,2,3,4,5,6,7,8,9|} -type f -exec grep \"${3:criteria}\" {} +`\n", + "description": "find files which contain search criteria" +} \ No newline at end of file diff --git a/nsroot/filesystem/file-write-multiline-sudo.json b/nsroot/filesystem/file-write-multiline-sudo.json new file mode 100644 index 0000000..608463a --- /dev/null +++ b/nsroot/filesystem/file-write-multiline-sudo.json @@ -0,0 +1,9 @@ +{ + "prefix": "file write multiline sudo", + "body": [ + "cat << EOL | sudo tee ${1:filepath}", + "${0:# text here}", + "EOL" + ], + "description": "write multiple lines into file with sudo permission" +} \ No newline at end of file diff --git a/nsroot/filesystem/file-write-multiline.json b/nsroot/filesystem/file-write-multiline.json new file mode 100644 index 0000000..682efbd --- /dev/null +++ b/nsroot/filesystem/file-write-multiline.json @@ -0,0 +1,9 @@ +{ + "prefix": "file write multiline", + "body": [ + "cat >${1:filepath} < ${2:/path/to/file}", + "for ${3:line} in \\${${4:lines}}; do", + "\techo \"\\$${3:line}\" >> ${2:/path/to/file}", + "done\n" + ], + "description": "write a file" +} \ No newline at end of file diff --git a/nsroot/filesystem/find-files-or-directories.json b/nsroot/filesystem/find-files-or-directories.json new file mode 100644 index 0000000..b699da8 --- /dev/null +++ b/nsroot/filesystem/find-files-or-directories.json @@ -0,0 +1,8 @@ +{ + "prefix": [ + "file find", + "directory find" + ], + "body": "result=`find ${1:./path} -maxdepth ${2|0,1,2,3,4,5,6,7,8,9|} -type ${3|f,d|} -name \"${4:criteria}\"`\n", + "description": "find files (-type f) or directories (-type d) by name" +} \ No newline at end of file diff --git a/nsroot/filesystem/if-directory-exists.json b/nsroot/filesystem/if-directory-exists.json new file mode 100644 index 0000000..9bf19d7 --- /dev/null +++ b/nsroot/filesystem/if-directory-exists.json @@ -0,0 +1,9 @@ +{ + "prefix": "if directory exists", + "body": [ + "if [ -d \"\\$${1:directory}\" ]; then", + "\t${0:echo directory exists}", + "fi\n" + ], + "description": "if directory exists" +} \ No newline at end of file diff --git a/nsroot/filesystem/if-file-executable.json b/nsroot/filesystem/if-file-executable.json new file mode 100644 index 0000000..546857b --- /dev/null +++ b/nsroot/filesystem/if-file-executable.json @@ -0,0 +1,9 @@ +{ + "prefix": "if file executable", + "body": [ + "if [ -x \"\\$${1:file}\" ]; then", + "\t${0:echo file is executable}", + "fi\n" + ], + "description": "if file executable" +} \ No newline at end of file diff --git a/nsroot/filesystem/if-file-exists-and-is-symbolic-link.json b/nsroot/filesystem/if-file-exists-and-is-symbolic-link.json new file mode 100644 index 0000000..7fad0bc --- /dev/null +++ b/nsroot/filesystem/if-file-exists-and-is-symbolic-link.json @@ -0,0 +1,9 @@ +{ + "prefix": "if file link", + "body": [ + "if [ -h \"\\$${1:file}\" ]; then", + "\t${0:echo symbolic link}", + "fi\n" + ], + "description": "if file exists and is a symbolic link" +} \ No newline at end of file diff --git a/nsroot/filesystem/if-file-exists.json b/nsroot/filesystem/if-file-exists.json new file mode 100644 index 0000000..b3c9fc8 --- /dev/null +++ b/nsroot/filesystem/if-file-exists.json @@ -0,0 +1,9 @@ +{ + "prefix": "if file exists", + "body": [ + "if [ -f \"\\$${1:file}\" ]; then", + "\t${2:echo file exists}", + "fi\n" + ], + "description": "if file exists" +} \ No newline at end of file diff --git a/nsroot/filesystem/if-file-not-empty.json b/nsroot/filesystem/if-file-not-empty.json new file mode 100644 index 0000000..7023cfb --- /dev/null +++ b/nsroot/filesystem/if-file-not-empty.json @@ -0,0 +1,9 @@ +{ + "prefix": "if file not empty", + "body": [ + "if [ -s \"\\$${1:file}\" ]; then", + "\t${2:echo file not empty}", + "fi\n" + ], + "description": "if file size is greater than zero" +} \ No newline at end of file diff --git a/nsroot/filesystem/if-file-readable.json b/nsroot/filesystem/if-file-readable.json new file mode 100644 index 0000000..22778b0 --- /dev/null +++ b/nsroot/filesystem/if-file-readable.json @@ -0,0 +1,9 @@ +{ + "prefix": "if file readable", + "body": [ + "if [ -r \"\\$${1:file}\" ]; then", + "\t${0:echo file is readable}", + "fi\n" + ], + "description": "if file readable" +} \ No newline at end of file diff --git a/nsroot/filesystem/if-file-writeable.json b/nsroot/filesystem/if-file-writeable.json new file mode 100644 index 0000000..4c86503 --- /dev/null +++ b/nsroot/filesystem/if-file-writeable.json @@ -0,0 +1,9 @@ +{ + "prefix": "if file writeable", + "body": [ + "if [ -w \"\\$${1:file}\" ]; then", + "\t${0:echo file is writeable}", + "fi\n" + ], + "description": "if file writeable" +} \ No newline at end of file diff --git a/nsroot/filesystem/if-file1-newer-than-file2.json b/nsroot/filesystem/if-file1-newer-than-file2.json new file mode 100644 index 0000000..a336312 --- /dev/null +++ b/nsroot/filesystem/if-file1-newer-than-file2.json @@ -0,0 +1,9 @@ +{ + "prefix": "if file newer", + "body": [ + "if [ \"\\$${1:file1}\" -nt \"\\$${2:file2}\" ]; then", + "\t${0:echo file1 is newer than file2}", + "fi\n" + ], + "description": "if file1 newer than file2" +} \ No newline at end of file diff --git a/nsroot/filesystem/if-file1-older-than-file2.json b/nsroot/filesystem/if-file1-older-than-file2.json new file mode 100644 index 0000000..8c9715c --- /dev/null +++ b/nsroot/filesystem/if-file1-older-than-file2.json @@ -0,0 +1,9 @@ +{ + "prefix": "if file older", + "body": [ + "if [ \"\\$${1:file1}\" -ot \"\\$${2:file2}\" ]; then", + "\t${0:echo file1 is older than file2}", + "fi\n" + ], + "description": "if file1 older than file2" +} \ No newline at end of file diff --git a/nsroot/filesystem/if-files-are-equal.json b/nsroot/filesystem/if-files-are-equal.json new file mode 100644 index 0000000..69f746b --- /dev/null +++ b/nsroot/filesystem/if-files-are-equal.json @@ -0,0 +1,9 @@ +{ + "prefix": "if file =", + "body": [ + "if [ \"\\$${1:file1}\" -ef \"\\$${2:file2}\" ]; then", + "\t${0:echo files are equal}", + "fi\n" + ], + "description": "if files are equal" +} \ No newline at end of file diff --git a/nsroot/filesystem/if-path-exists.json b/nsroot/filesystem/if-path-exists.json new file mode 100644 index 0000000..22ff7dc --- /dev/null +++ b/nsroot/filesystem/if-path-exists.json @@ -0,0 +1,9 @@ +{ + "prefix": "if exists", + "body": [ + "if [ -e \"\\$${1:path}\" ]; then", + "\t${0:echo exists}", + "fi\n" + ], + "description": "if path exists (file, directory, link...)" +} \ No newline at end of file diff --git a/nsroot/filesystem/remove-files-older-than.json b/nsroot/filesystem/remove-files-older-than.json new file mode 100644 index 0000000..43a3b5a --- /dev/null +++ b/nsroot/filesystem/remove-files-older-than.json @@ -0,0 +1,5 @@ +{ + "prefix": "remove files older", + "body": "find \"\\$${1:path}\" -mtime +${2:days} | xargs rm -f\n", + "description": "find and remove files older than x days" +} \ No newline at end of file diff --git a/nsroot/fn-fx/fn-banner-color.json b/nsroot/fn-fx/fn-banner-color.json new file mode 100644 index 0000000..2c51d68 --- /dev/null +++ b/nsroot/fn-fx/fn-banner-color.json @@ -0,0 +1,44 @@ +{ + "prefix": "fn banner color", + "body": [ + "# Usage: banner_color green \"my title\"\n", + "function banner_color() {", + "\tlocal color=\\$1", + "\tshift\n", + "\tcase \\$color in", + "\t\tblack) color=0", + "\t\t;;", + "\t\tred) color=1", + "\t\t;;", + "\t\tgreen) color=2", + "\t\t;;", + "\t\tyellow) color=3", + "\t\t;;", + "\t\tblue) color=4", + "\t\t;;", + "\t\tmagenta) color=5", + "\t\t;;", + "\t\tcyan) color=6", + "\t\t;;", + "\t\twhite) color=7", + "\t\t;;", + "\t\t*) echo \"color is not set\"; exit 1", + "\t\t;;", + "\tesac\n", + "\tlocal s=(\"$@\") b w", + "\tfor l in \"\\${s[@]}\"; do", + "\t\t((w<${#l})) && { b=\"\\$l\"; w=\"\\${#l}\"; }", + "\tdone", + "\ttput setaf \\$color", + "\techo \" =\\${b//?/=}=", + "| \\${b//?/ } |\"", + "\tfor l in \"\\${s[@]}\"; do", + "\t\tprintf '| %s%*s%s |\\n' \"\\$(tput setaf \\$color)\" \"-\\$w\" \"\\$l\" \"\\$(tput setaf \\$color)\"", + "\tdone\n", + "\techo \"| ${b//?/ } |", + " =${b//?/=}=\"", + "\ttput sgr 0", + "}\n" + ], + "description": "print a color banner." +} \ No newline at end of file diff --git a/nsroot/fn-fx/fn-banner-simple.json b/nsroot/fn-fx/fn-banner-simple.json new file mode 100644 index 0000000..0441487 --- /dev/null +++ b/nsroot/fn-fx/fn-banner-simple.json @@ -0,0 +1,15 @@ +{ + "prefix": "fn banner simple", + "body": [ + "# Usage: banner_simple \"my title\"\n", + "function banner_simple() {", + "\tlocal msg=\"* \\$* *\"", + "\tlocal edge=`echo \"\\$msg\" | sed 's/./*/g'`", + "\techo \"\\$edge\"", + "\techo \"`tput bold`\\$msg`tput sgr0`\"", + "\techo \"\\$edge\"", + "\techo", + "}\n" + ], + "description": "function: print a banner with provided title" +} \ No newline at end of file diff --git a/nsroot/fn-fx/fn-import.json b/nsroot/fn-fx/fn-import.json new file mode 100644 index 0000000..13300eb --- /dev/null +++ b/nsroot/fn-fx/fn-import.json @@ -0,0 +1,16 @@ +{ + "prefix": "fn import", + "body": [ + "# Usage: import \"mylib\"\n", + "function import() {", + "\tlocal file=\"./${0:lib}/\\$1.sh\"", + "\tif [ -f \"\\$file\" ]; then", + "\t\tsource \"\\$file\"", + "\telse", + "\t\techo \"Error: Cannot find library at: \\$file\"", + "\t\texit 1", + "\tfi", + "}\n" + ], + "description": "import functions from other shellscript files" +} \ No newline at end of file diff --git a/nsroot/fn-fx/fn-math-average.json b/nsroot/fn-fx/fn-math-average.json new file mode 100644 index 0000000..e3535f4 --- /dev/null +++ b/nsroot/fn-fx/fn-math-average.json @@ -0,0 +1,13 @@ +{ + "prefix": "fn math average", + "body": [ + "function average () {", + "\tlocal result=0", + "\tfor item in \\$@; do", + "\t\t((result += item))", + "\tdone", + "\techo \\$((result / \\$#))", + "}\n" + ], + "description": "Calculate average of given integers" +} \ No newline at end of file diff --git a/nsroot/fn-fx/fn-math-product.json b/nsroot/fn-fx/fn-math-product.json new file mode 100644 index 0000000..25d12a2 --- /dev/null +++ b/nsroot/fn-fx/fn-math-product.json @@ -0,0 +1,13 @@ +{ + "prefix": "fn math product", + "body": [ + "function product () {", + "\tlocal result=1", + "\tfor item in $@; do", + "\t\t((result *= item))", + "\tdone", + "\techo \\$result", + "}\n" + ], + "description": "Calculate product of given integers" +} \ No newline at end of file diff --git a/nsroot/fn-fx/fn-math-sum.json b/nsroot/fn-fx/fn-math-sum.json new file mode 100644 index 0000000..9443123 --- /dev/null +++ b/nsroot/fn-fx/fn-math-sum.json @@ -0,0 +1,13 @@ +{ + "prefix": "fn math sum", + "body": [ + "function sum () {", + "\tlocal result=0", + "\tfor item in \\$@; do", + "\t\t((result += item))", + "\tdone", + "\techo \\$result", + "}\n" + ], + "description": "Calculate sum of given integers" +} \ No newline at end of file diff --git a/nsroot/fn-fx/fn-options.json b/nsroot/fn-fx/fn-options.json new file mode 100644 index 0000000..beef156 --- /dev/null +++ b/nsroot/fn-fx/fn-options.json @@ -0,0 +1,47 @@ +{ + "prefix": "fn options", + "body": [ + "# Usage: options=(\"one\" \"two\" \"three\"); chooseOption \"Choose:\" 1 \"\\${options[@]}\"; choice=\\$?; echo \"\\${options[\\$choice]}\"\n", + "function chooseOption() {", + "\techo \"\\$1\"; shift", + "\techo `tput sitm``tput dim`-\"Change selection: [up/down] Select: [ENTER]\" `tput sgr0`", + "\tlocal selected=\"\\$1\"; shift\n", + "\tESC=`echo -e \"\\033\"`", + "\tcursor_blink_on() { tput cnorm; }", + "\tcursor_blink_off() { tput civis; }", + "\tcursor_to() { tput cup \\$((\\$1-1)); }", + "\tprint_option() { echo `tput dim` \" \\$1\" `tput sgr0`; }", + "\tprint_selected() { echo `tput bold` \"=> \\$1\" `tput sgr0`; }", + "\tget_cursor_row() { IFS=';' read -sdR -p \\$'\\E[6n' ROW COL; echo \\${ROW#*[}; }", + "\tkey_input() { read -s -n3 key 2>/dev/null >&2; [[ \\$key = \\$ESC[A ]] && echo up; [[ \\$key = \\$ESC[B ]] && echo down; [[ \\$key = \"\" ]] && echo enter; }\n", + "\tfor opt; do echo; done\n", + "\tlocal lastrow=`get_cursor_row`", + "\tlocal startrow=\\$((\\$lastrow - \\$#))", + "\ttrap \"cursor_blink_on; echo; echo; exit\" 2", + "\tcursor_blink_off\n", + "\t: selected:=0\n", + "\twhile true; do", + "\t\tlocal idx=0", + "\t\tfor opt; do", + "\t\t\tcursor_to \\$((\\$startrow + \\$idx))", + "\t\t\tif [ \\$idx -eq \\$selected ]; then", + "\t\t\t\tprint_selected \"\\$opt\"", + "\t\t\telse", + "\t\t\t\tprint_option \"\\$opt\"", + "\t\t\tfi", + "\t\t\t((idx++))", + "\t\tdone\n", + "\t\tcase `key_input` in", + "\t\t\tenter) break;;", + "\t\t\tup) ((selected--)); [ \\$selected -lt 0 ] && selected=\\$((\\$# - 1));;", + "\t\t\tdown) ((selected++)); [ \\$selected -ge \\$# ] && selected=0;;", + "\t\tesac", + "\tdone\n", + "\tcursor_to \\$lastrow", + "\tcursor_blink_on", + "\techo\n", + "\treturn \\$selected", + "}\n" + ], + "description": "provide a list of options to user and return the index of selected option" +} \ No newline at end of file diff --git a/nsroot/fn-fx/fn-progress.json b/nsroot/fn-fx/fn-progress.json new file mode 100644 index 0000000..239bf98 --- /dev/null +++ b/nsroot/fn-fx/fn-progress.json @@ -0,0 +1,15 @@ +{ + "prefix": "fn progress", + "body": [ + "function progressBar() {", + "\tlocal BAR='████████████████████'", + "\tlocal SPACE=' '", + "\tfor i in {1..20}; do", + "\t\techo -ne \"\\r|\\${BAR:0:\\$i}\\${SPACE:\\$i:20}| \\$((\\$i*5))% [ \\$2 ] \"", + "\t\tsleep \\$1", + "\tdone", + "\techo -ne '\n'", + "}\n" + ], + "description": "progress bar function" +} \ No newline at end of file diff --git a/nsroot/fn-fx/fn-scan.json b/nsroot/fn-fx/fn-scan.json new file mode 100644 index 0000000..2004a74 --- /dev/null +++ b/nsroot/fn-fx/fn-scan.json @@ -0,0 +1,12 @@ +{ + "prefix": "fn scan", + "body": [ + "# Usage: scan proto host fromPort toPort", + "function scan () {", + "\tfor ((port=\\$3; port<=\\$4; port++)); do", + "\t\t(echo >/dev/\\$1/\\$2/\\$port) >/dev/null 2>&1 && echo \"\\$1 \\$port => open\"", + "\tdone", + "}\n" + ], + "description": "Scan host's port range (tcp/udp)" +} \ No newline at end of file diff --git a/nsroot/fn-fx/fn-version-compare.json b/nsroot/fn-fx/fn-version-compare.json new file mode 100644 index 0000000..2ffb3db --- /dev/null +++ b/nsroot/fn-fx/fn-version-compare.json @@ -0,0 +1,36 @@ +{ + "prefix": [ + "fn version compare", + "fn semver compare" + ], + "body": [ + "# Usage: version_compare \"1.2.3\" \"1.1.7\"\n", + "function version_compare () {", + "\tfunction sub_ver () {", + "\t\tlocal len=${#1}", + "\t\ttemp=${1%%\".\"*} && indexOf=`echo ${1%%\".\"*} | echo ${#temp}`", + "\t\techo -e \"\\${1:0:indexOf}\"", + "\t}", + "\tfunction cut_dot () {", + "\t\tlocal offset=${#1}", + "\t\tlocal length=${#2}", + "\t\techo -e \"\\${2:((++offset)):length}\"", + "\t}", + "\tif [ -z \"\\$1\" ] || [ -z \"\\$2\" ]; then", + "\t\techo \"=\" && exit 0", + "\tfi", + "\tlocal v1=`echo -e \"\\${1}\" | tr -d '[[:space:]]'`", + "\tlocal v2=`echo -e \"\\${2}\" | tr -d '[[:space:]]'`", + "\tlocal v1_sub=`sub_ver \\$v1`", + "\tlocal v2_sub=`sub_ver \\$v2`", + "\tif (( v1_sub > v2_sub )); then", + "\t\techo \">\"", + "\telif (( v1_sub < v2_sub )); then", + "\t\techo \"<\"", + "\telse", + "\t\tversion_compare `cut_dot \\$v1_sub \\$v1` `cut_dot \\$v2_sub \\$v2`", + "\tfi", + "}\n" + ], + "description": "function: compares two semvers and returns >, < or =" +} \ No newline at end of file diff --git a/nsroot/fn-fx/fx-banner-color.json b/nsroot/fn-fx/fx-banner-color.json new file mode 100644 index 0000000..842a183 --- /dev/null +++ b/nsroot/fn-fx/fx-banner-color.json @@ -0,0 +1,5 @@ +{ + "prefix": "fx banner color", + "body": "banner_color ${1|black,red,green,yellow,blue,magenta,cyan,white|} \"${2:my title}\"\n", + "description": "call banner_color function" +} \ No newline at end of file diff --git a/nsroot/fn-fx/fx-banner-simple.json b/nsroot/fn-fx/fx-banner-simple.json new file mode 100644 index 0000000..0fb0c1f --- /dev/null +++ b/nsroot/fn-fx/fx-banner-simple.json @@ -0,0 +1,5 @@ +{ + "prefix": "fx banner simple", + "body": "banner_simple \"${1:my title}\"\n", + "description": "call banner_simple function" +} \ No newline at end of file diff --git a/nsroot/fn-fx/fx-import.json b/nsroot/fn-fx/fx-import.json new file mode 100644 index 0000000..3424a65 --- /dev/null +++ b/nsroot/fn-fx/fx-import.json @@ -0,0 +1,5 @@ +{ + "prefix": "fx import", + "body": "import \"${1:libname}\"\n", + "description": "call import function, to import functions from other shellscript files located in a directory (default: lib) relative to current script file" +} \ No newline at end of file diff --git a/nsroot/fn-fx/fx-math-average.json b/nsroot/fn-fx/fx-math-average.json new file mode 100644 index 0000000..0f480b3 --- /dev/null +++ b/nsroot/fn-fx/fx-math-average.json @@ -0,0 +1,5 @@ +{ + "prefix": "fx math average", + "body": "result=`average ${1:\\$var1} ${2:\\$var2} ${3:\\$var3}`\n", + "description": "Call math average function" +} \ No newline at end of file diff --git a/nsroot/fn-fx/fx-math-product.json b/nsroot/fn-fx/fx-math-product.json new file mode 100644 index 0000000..3378952 --- /dev/null +++ b/nsroot/fn-fx/fx-math-product.json @@ -0,0 +1,5 @@ +{ + "prefix": "fx math product", + "body": "result=`product ${1:\\$var1} ${2:\\$var2} ${3:\\$var3}`\n", + "description": "Call math product function" +} \ No newline at end of file diff --git a/nsroot/fn-fx/fx-math-sum.json b/nsroot/fn-fx/fx-math-sum.json new file mode 100644 index 0000000..b3b3fa1 --- /dev/null +++ b/nsroot/fn-fx/fx-math-sum.json @@ -0,0 +1,5 @@ +{ + "prefix": "fx math sum", + "body": "result=`sum ${1:\\$var1} ${2:\\$var2} ${3:\\$var3}`\n", + "description": "Call math sum function" +} \ No newline at end of file diff --git a/nsroot/fn-fx/fx-options.json b/nsroot/fn-fx/fx-options.json new file mode 100644 index 0000000..6913862 --- /dev/null +++ b/nsroot/fn-fx/fx-options.json @@ -0,0 +1,9 @@ +{ + "prefix": "fx options", + "body": [ + "options=(${1:\"one\" \"two\" \"three\"})", + "chooseOption \"Choose:\" ${2:1} \"\\${options[@]}\"; choice=\\$?", + "echo \"\\${options[\\$choice]}\" selected\n" + ], + "description": "call options function" +} \ No newline at end of file diff --git a/nsroot/fn-fx/fx-progress.json b/nsroot/fn-fx/fx-progress.json new file mode 100644 index 0000000..172962f --- /dev/null +++ b/nsroot/fn-fx/fx-progress.json @@ -0,0 +1,5 @@ +{ + "prefix": "fx progress", + "body": "progressBar ${1|.1,.2,.3,.4,.5,1,2,5|} \"${2:Installing foo...}\"\n", + "description": "call progress bar function" +} \ No newline at end of file diff --git a/nsroot/fn-fx/fx-scan.json b/nsroot/fn-fx/fx-scan.json new file mode 100644 index 0000000..737060a --- /dev/null +++ b/nsroot/fn-fx/fx-scan.json @@ -0,0 +1,5 @@ +{ + "prefix": "fx scan", + "body": "scan ${1|tcp,udp|} ${2:host} ${3:fromPort} ${4: toPort}", + "description": "call scan function to scan a host over a port range" +} \ No newline at end of file diff --git a/nsroot/fn-fx/fx-version-compare.json b/nsroot/fn-fx/fx-version-compare.json new file mode 100644 index 0000000..19cd46b --- /dev/null +++ b/nsroot/fn-fx/fx-version-compare.json @@ -0,0 +1,8 @@ +{ + "prefix": [ + "fx version compare", + "fx semver compare" + ], + "body": "version_compare \"${1:major}.${2:minor}.${3:patch}\" \"${4:major}.${5:minor}.${6:patch}\"\n", + "description": "call version_compare function" +} \ No newline at end of file diff --git a/nsroot/ftp/delete.json b/nsroot/ftp/delete.json new file mode 100644 index 0000000..e875a11 --- /dev/null +++ b/nsroot/ftp/delete.json @@ -0,0 +1,5 @@ +{ + "prefix": "ftp delete file", + "body": "curl ftp://${1:user}:${2:password}@${3:ipOrDomain}/${4:path}/${5:fileToDelete} -Q \"DELE ${5:fileToDelete}\"\n", + "description": "Delete specified file from ftp server" +} \ No newline at end of file diff --git a/nsroot/ftp/download.json b/nsroot/ftp/download.json new file mode 100644 index 0000000..6482c88 --- /dev/null +++ b/nsroot/ftp/download.json @@ -0,0 +1,5 @@ +{ + "prefix": "ftp download", + "body": "curl ftp://${1:user}:${2:password}@${3:ipOrDomain}/${4:filePathOnServer}/\n", + "description": "Download specified file from ftp server" +} \ No newline at end of file diff --git a/nsroot/ftp/list-of-files.json b/nsroot/ftp/list-of-files.json new file mode 100644 index 0000000..0072e74 --- /dev/null +++ b/nsroot/ftp/list-of-files.json @@ -0,0 +1,5 @@ +{ + "prefix": "ftp list", + "body": "curl ftp://${1:user}:${2:password}@${3:ipOrDomain}/${4:directoryPathOnServer}/\n", + "description": "Get the list of files on the ftp server at specific path" +} \ No newline at end of file diff --git a/nsroot/ftp/rename.json b/nsroot/ftp/rename.json new file mode 100644 index 0000000..aad5ad8 --- /dev/null +++ b/nsroot/ftp/rename.json @@ -0,0 +1,5 @@ +{ + "prefix": "ftp rename", + "body": "curl ftp://${1:user}:${2:password}@${3:ipOrDomain}/${4:path}/ -Q \"-RNFR ${4:path}/${5:renameFrom}\" -Q \"-RNTO ${4:path}/${6:renameTo}\"\n", + "description": "Rename specified file/directory on ftp server" +} \ No newline at end of file diff --git a/nsroot/ftp/upload.json b/nsroot/ftp/upload.json new file mode 100644 index 0000000..de85b58 --- /dev/null +++ b/nsroot/ftp/upload.json @@ -0,0 +1,5 @@ +{ + "prefix": "ftp upload", + "body": "curl -T ${1:fileToUpload} ftp://${2:user}:${3:password}@${4:ipOrDomain}/${5:directoryPathOnServer}/\n", + "description": "Upload specified file to ftp server" +} \ No newline at end of file diff --git a/nsroot/function/arguments-array.json b/nsroot/function/arguments-array.json new file mode 100644 index 0000000..613096c --- /dev/null +++ b/nsroot/function/arguments-array.json @@ -0,0 +1,5 @@ +{ + "prefix": "func args", + "body": "echo \"$@\"", + "description": "function arguments array" +} \ No newline at end of file diff --git a/nsroot/function/arguments-count.json b/nsroot/function/arguments-count.json new file mode 100644 index 0000000..7bc8ec0 --- /dev/null +++ b/nsroot/function/arguments-count.json @@ -0,0 +1,5 @@ +{ + "prefix": "func args count", + "body": "echo $#", + "description": "number of function arguments" +} \ No newline at end of file diff --git a/nsroot/function/declare.json b/nsroot/function/declare.json new file mode 100644 index 0000000..ad95751 --- /dev/null +++ b/nsroot/function/declare.json @@ -0,0 +1,9 @@ +{ + "prefix": "func", + "body": [ + "function ${1:name} () {", + "\t${2:echo \"\\$1\" # arguments are accessible through $1, $2,...}", + "}\n" + ], + "description": "function" +} \ No newline at end of file diff --git a/nsroot/function/return-value.json b/nsroot/function/return-value.json new file mode 100644 index 0000000..460ebea --- /dev/null +++ b/nsroot/function/return-value.json @@ -0,0 +1,5 @@ +{ + "prefix": "func ret val", + "body": "echo \"$?\"", + "description": "last function/command return code" +} \ No newline at end of file diff --git a/nsroot/git/branch-create.json b/nsroot/git/branch-create.json new file mode 100644 index 0000000..9ed3f0b --- /dev/null +++ b/nsroot/git/branch-create.json @@ -0,0 +1,5 @@ +{ + "prefix": "git branch create", + "body": "git checkout -b ${1:branchName}\n", + "description": "Create branch locally and switch into it." +} \ No newline at end of file diff --git a/nsroot/git/branch-delete-local.json b/nsroot/git/branch-delete-local.json new file mode 100644 index 0000000..accfb82 --- /dev/null +++ b/nsroot/git/branch-delete-local.json @@ -0,0 +1,5 @@ +{ + "prefix": "git branch delete local", + "body": "git branch --delete ${1:localBranch}\n", + "description": "Delete local branch." +} \ No newline at end of file diff --git a/nsroot/git/branch-delete-remote.json b/nsroot/git/branch-delete-remote.json new file mode 100644 index 0000000..422a4e8 --- /dev/null +++ b/nsroot/git/branch-delete-remote.json @@ -0,0 +1,5 @@ +{ + "prefix": "git branch delete remote", + "body": "git push origin --delete ${1:remoteBranch}\n", + "description": "Delete remote branch." +} \ No newline at end of file diff --git a/nsroot/git/branch-list.json b/nsroot/git/branch-list.json new file mode 100644 index 0000000..c65e2ef --- /dev/null +++ b/nsroot/git/branch-list.json @@ -0,0 +1,5 @@ +{ + "prefix": "git branch list", + "body": "git branch\n", + "description": "List all branches." +} \ No newline at end of file diff --git a/nsroot/git/branch-push.json b/nsroot/git/branch-push.json new file mode 100644 index 0000000..07309d6 --- /dev/null +++ b/nsroot/git/branch-push.json @@ -0,0 +1,5 @@ +{ + "prefix": "git branch push", + "body": "git push origin ${1:branchName}\n", + "description": "Push branch to remote." +} \ No newline at end of file diff --git a/nsroot/git/branch-rename.json b/nsroot/git/branch-rename.json new file mode 100644 index 0000000..a95f304 --- /dev/null +++ b/nsroot/git/branch-rename.json @@ -0,0 +1,5 @@ +{ + "prefix": "git branch rename", + "body": "git branch -m ${1:newName}\n", + "description": "Rename current branch." +} \ No newline at end of file diff --git a/nsroot/git/changes-revert.json b/nsroot/git/changes-revert.json new file mode 100644 index 0000000..a5aa71f --- /dev/null +++ b/nsroot/git/changes-revert.json @@ -0,0 +1,5 @@ +{ + "prefix": "git changes revert", + "body": "git checkout .\n", + "description": "Revert tracked changes" +} \ No newline at end of file diff --git a/nsroot/git/clone-branch.json b/nsroot/git/clone-branch.json new file mode 100644 index 0000000..525ec2a --- /dev/null +++ b/nsroot/git/clone-branch.json @@ -0,0 +1,5 @@ +{ + "prefix": "git clone branch", + "body": "git clone -b ${1:branchName} https://${2:github.com}/${3:user}/${4:repository}.git\n", + "description": "Clone a remote branch to local machine." +} \ No newline at end of file diff --git a/nsroot/git/clone.json b/nsroot/git/clone.json new file mode 100644 index 0000000..46ea8c3 --- /dev/null +++ b/nsroot/git/clone.json @@ -0,0 +1,5 @@ +{ + "prefix": "git clone", + "body": "git clone https://${1:github.com}/${2:user}/${3:repository}.git\n", + "description": "Clone remote repository to local machine." +} \ No newline at end of file diff --git a/nsroot/git/commit-list.json b/nsroot/git/commit-list.json new file mode 100644 index 0000000..514b42d --- /dev/null +++ b/nsroot/git/commit-list.json @@ -0,0 +1,5 @@ +{ + "prefix": "git commit list notPushed", + "body": "git log origin/master..HEAD\n", + "description": "List non pushed commits." +} \ No newline at end of file diff --git a/nsroot/git/commit-search.json b/nsroot/git/commit-search.json new file mode 100644 index 0000000..f69441b --- /dev/null +++ b/nsroot/git/commit-search.json @@ -0,0 +1,5 @@ +{ + "prefix": "git commit search", + "body": "git log --all --grep='${1:searchCriteria}'\n", + "description": "Search for a commit which contains searchCriteria." +} \ No newline at end of file diff --git a/nsroot/git/commit-undo.json b/nsroot/git/commit-undo.json new file mode 100644 index 0000000..53b15d8 --- /dev/null +++ b/nsroot/git/commit-undo.json @@ -0,0 +1,5 @@ +{ + "prefix": "git commit undo", + "body": "git reset --${1|soft,hard|} HEAD~${2|1,2,3,4,5|}\n", + "description": "Undo last N commits (soft: preserve local changes | hard: delete local changes" +} \ No newline at end of file diff --git a/nsroot/git/commit.json b/nsroot/git/commit.json new file mode 100644 index 0000000..b4d7f08 --- /dev/null +++ b/nsroot/git/commit.json @@ -0,0 +1,5 @@ +{ + "prefix": "git commit", + "body": "git commit -m \"${1:commit message}\"\n", + "description": "Commit changes." +} \ No newline at end of file diff --git a/nsroot/git/config-list.json b/nsroot/git/config-list.json new file mode 100644 index 0000000..3cf66e8 --- /dev/null +++ b/nsroot/git/config-list.json @@ -0,0 +1,5 @@ +{ + "prefix": "git config list", + "body": "git config --list\n", + "description": "List git configurations." +} \ No newline at end of file diff --git a/nsroot/git/config-set.json b/nsroot/git/config-set.json new file mode 100644 index 0000000..64879fa --- /dev/null +++ b/nsroot/git/config-set.json @@ -0,0 +1,5 @@ +{ + "prefix": "git config set", + "body": "git config --${1|local,global|} ${2|user.name,user.email|} \"${3:value}\"\n", + "description": "Configure git." +} \ No newline at end of file diff --git a/nsroot/git/patch-apply.json b/nsroot/git/patch-apply.json new file mode 100644 index 0000000..cfb84d2 --- /dev/null +++ b/nsroot/git/patch-apply.json @@ -0,0 +1,5 @@ +{ + "prefix": "git patch apply", + "body": "git apply < ${0:/path/to/patch1.patch}\n", + "description": "Apply a patch from file." +} \ No newline at end of file diff --git a/nsroot/git/patch-create.json b/nsroot/git/patch-create.json new file mode 100644 index 0000000..5836db1 --- /dev/null +++ b/nsroot/git/patch-create.json @@ -0,0 +1,5 @@ +{ + "prefix": "git patch create", + "body": "git diff > ${0:/path/to/patch1.patch}\n", + "description": "Create a patch from changes." +} \ No newline at end of file diff --git a/nsroot/git/remote-list.json b/nsroot/git/remote-list.json new file mode 100644 index 0000000..80eda63 --- /dev/null +++ b/nsroot/git/remote-list.json @@ -0,0 +1,5 @@ +{ + "prefix": "git remote list", + "body": "git remote\n", + "description": "List all remotes." +} \ No newline at end of file diff --git a/nsroot/git/remote-url-change.json b/nsroot/git/remote-url-change.json new file mode 100644 index 0000000..d86fd2b --- /dev/null +++ b/nsroot/git/remote-url-change.json @@ -0,0 +1,5 @@ +{ + "prefix": "git remote urlChange", + "body": "git remote set-url origin https://${1:github.com}/${2:user}/${3:repository}.git\n", + "description": "Change remote url." +} \ No newline at end of file diff --git a/nsroot/git/remote-urlAdd.json b/nsroot/git/remote-urlAdd.json new file mode 100644 index 0000000..8622f95 --- /dev/null +++ b/nsroot/git/remote-urlAdd.json @@ -0,0 +1,5 @@ +{ + "prefix": "git remote urlAdd", + "body": "git remote add origin https://${1:github.com}/${2:user}/${3:repository}.git\n", + "description": "Add remote url." +} \ No newline at end of file diff --git a/nsroot/git/tag-commit.json b/nsroot/git/tag-commit.json new file mode 100644 index 0000000..2dfb198 --- /dev/null +++ b/nsroot/git/tag-commit.json @@ -0,0 +1,8 @@ +{ + "prefix": [ + "git tag commit", + "git commit tag" + ], + "body": "git tag -a ${1:release/1.0.0} -m \"${2:1.0.0 release}\"\n", + "description": "Tag a commit." +} \ No newline at end of file diff --git a/nsroot/git/tag-list.json b/nsroot/git/tag-list.json new file mode 100644 index 0000000..db953a0 --- /dev/null +++ b/nsroot/git/tag-list.json @@ -0,0 +1,5 @@ +{ + "prefix": "git tag list", + "body": "git tag\n", + "description": "List all tags." +} \ No newline at end of file diff --git a/nsroot/git/tag-remote-delete.json b/nsroot/git/tag-remote-delete.json new file mode 100644 index 0000000..a980ab7 --- /dev/null +++ b/nsroot/git/tag-remote-delete.json @@ -0,0 +1,5 @@ +{ + "prefix": "git tag remote delete", + "body": "git push --delete origin ${1:tagName} && git push origin :${1:tagName}\n", + "description": "Delete tag from remote." +} \ No newline at end of file diff --git a/nsroot/git/tag-remote-push.json b/nsroot/git/tag-remote-push.json new file mode 100644 index 0000000..e745a80 --- /dev/null +++ b/nsroot/git/tag-remote-push.json @@ -0,0 +1,5 @@ +{ + "prefix": "git tag remote push", + "body": "git push origin ${1:tagName}\n", + "description": "Push tag to remote." +} \ No newline at end of file diff --git a/nsroot/http/cookie.json b/nsroot/http/cookie.json new file mode 100644 index 0000000..1983362 --- /dev/null +++ b/nsroot/http/cookie.json @@ -0,0 +1,10 @@ +{ + "prefix": "http cookie", + "body": [ + "curl --request ${1|GET,POST,DELETE,PUT|} -sL \\", + "\t--user-agent '${2|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \\", + "\t--cookie '${3:key}=${4:value}' \\", + "\t--url '${5:http://example.com}'\n" + ], + "description": "Send http request with cookies, using curl" +} \ No newline at end of file diff --git a/nsroot/http/download.json b/nsroot/http/download.json new file mode 100644 index 0000000..b7cd3d7 --- /dev/null +++ b/nsroot/http/download.json @@ -0,0 +1,10 @@ +{ + "prefix": "http download", + "body": [ + "curl --request ${1|GET,POST|} -sL \\", + "\t--user-agent '${2|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \\", + "\t--output '${3:/path/to/file}' \\", + "\t--url '${4:http://example.com/file.zip}'\n" + ], + "description": "Download from url and save to /path/to/file, using curl" +} \ No newline at end of file diff --git a/nsroot/http/get.json b/nsroot/http/get.json new file mode 100644 index 0000000..f573d1b --- /dev/null +++ b/nsroot/http/get.json @@ -0,0 +1,12 @@ +{ + "prefix": [ + "http GET", + "http DELETE" + ], + "body": [ + "curl --request ${1|GET,DELETE|} -sL \\", + "\t--user-agent '${2|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \\", + "\t--url '${3:http://example.com}'\n" + ], + "description": "Send http GET/DELETE request using curl" +} \ No newline at end of file diff --git a/nsroot/http/header.json b/nsroot/http/header.json new file mode 100644 index 0000000..812ae72 --- /dev/null +++ b/nsroot/http/header.json @@ -0,0 +1,10 @@ +{ + "prefix": "http header", + "body": [ + "curl --request ${1|GET,POST,DELETE,PUT|} -sL \\", + "\t--user-agent '${2|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \\", + "\t--header '${3:key}: ${4:value}' \\", + "\t--url '${5:http://example.com}'\n" + ], + "description": "Send http request with custom header, using curl" +} \ No newline at end of file diff --git a/nsroot/http/post-send-file.json b/nsroot/http/post-send-file.json new file mode 100644 index 0000000..1f719d1 --- /dev/null +++ b/nsroot/http/post-send-file.json @@ -0,0 +1,11 @@ +{ + "prefix": "http POST file", + "body": [ + "curl --request POST -sL \\", + "\t--user-agent '${1|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \\", + "\t--url '${2:http://example.com}' \\", + "\t--form '${3:key}=${4:value}' \\", + "\t--form 'file=@${5:/path/to/file}'\n" + ], + "description": "Send file with http POST, using curl" +} \ No newline at end of file diff --git a/nsroot/http/post.json b/nsroot/http/post.json new file mode 100644 index 0000000..38c30a3 --- /dev/null +++ b/nsroot/http/post.json @@ -0,0 +1,14 @@ +{ + "prefix": [ + "http POST", + "http PUT" + ], + "body": [ + "curl --request ${1|POST,PUT|} -sL \\", + "\t--user-agent '${2|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \\", + "\t--url '${3:http://example.com}' \\", + "\t--data '${4:key}=${5:value}' \\", + "\t--data '${6:key}=${7:value}'\n" + ], + "description": "Send data with http POST/PUT, using curl" +} \ No newline at end of file diff --git a/nsroot/input/ask-question.json b/nsroot/input/ask-question.json new file mode 100644 index 0000000..2b75a40 --- /dev/null +++ b/nsroot/input/ask-question.json @@ -0,0 +1,8 @@ +{ + "prefix": "ask question", + "body": [ + "read -ep \"${1:Question here? }\" -i ${2:Default answer} ANSWER", + "${3:echo \"\\$ANSWER\"}\n" + ], + "description": "Ask question with default answer" +} \ No newline at end of file diff --git a/nsroot/integer/if-equal.json b/nsroot/integer/if-equal.json new file mode 100644 index 0000000..0bf2cef --- /dev/null +++ b/nsroot/integer/if-equal.json @@ -0,0 +1,9 @@ +{ + "prefix": "if int =", + "body": [ + "if (( ${1:int1} == ${2:int2} )); then", + "\t${3:echo equal}", + "fi\n" + ], + "description": "if integers are equal" +} \ No newline at end of file diff --git a/nsroot/integer/if-greater-or-equal.json b/nsroot/integer/if-greater-or-equal.json new file mode 100644 index 0000000..9243ef9 --- /dev/null +++ b/nsroot/integer/if-greater-or-equal.json @@ -0,0 +1,9 @@ +{ + "prefix": "if int >=", + "body": [ + "if (( ${1:int} >= ${2:val} )); then", + "\t${3:echo greater equal}", + "fi\n" + ], + "description": "if integer greater than or equal value" +} \ No newline at end of file diff --git a/nsroot/integer/if-greater.json b/nsroot/integer/if-greater.json new file mode 100644 index 0000000..5d42037 --- /dev/null +++ b/nsroot/integer/if-greater.json @@ -0,0 +1,9 @@ +{ + "prefix": "if int >", + "body": [ + "if (( ${1:int} > ${2:val} )); then", + "\t${3:echo greater}", + "fi\n" + ], + "description": "if integer greater than value" +} \ No newline at end of file diff --git a/nsroot/integer/if-lesser-or-equal.json b/nsroot/integer/if-lesser-or-equal.json new file mode 100644 index 0000000..5038753 --- /dev/null +++ b/nsroot/integer/if-lesser-or-equal.json @@ -0,0 +1,9 @@ +{ + "prefix": "if int <=", + "body": [ + "if (( ${1:int} <= ${2:val} )); then", + "\t${3:echo lesser equal}", + "fi\n" + ], + "description": "if integer lesser than or equal value" +} \ No newline at end of file diff --git a/nsroot/integer/if-lesser.json b/nsroot/integer/if-lesser.json new file mode 100644 index 0000000..cbb9cc2 --- /dev/null +++ b/nsroot/integer/if-lesser.json @@ -0,0 +1,9 @@ +{ + "prefix": "if int <", + "body": [ + "if (( ${1:int} < ${2:val} )); then", + "\t${3:echo lesser}", + "fi\n" + ], + "description": "if integer lesser than value" +} \ No newline at end of file diff --git a/nsroot/integer/if-not-equal.json b/nsroot/integer/if-not-equal.json new file mode 100644 index 0000000..72a6a69 --- /dev/null +++ b/nsroot/integer/if-not-equal.json @@ -0,0 +1,9 @@ +{ + "prefix": "if int !=", + "body": [ + "if (( ${1:int1} != ${2:int2} )); then", + "\t${3:echo not equal}", + "fi\n" + ], + "description": "if integers are not equal" +} \ No newline at end of file diff --git a/nsroot/ip/array-of-local.json b/nsroot/ip/array-of-local.json new file mode 100644 index 0000000..5d3ed35 --- /dev/null +++ b/nsroot/ip/array-of-local.json @@ -0,0 +1,5 @@ +{ + "prefix": "ips", + "body": "IPS=`hostname -I`\n", + "description": "Array of local IPs" +} \ No newline at end of file diff --git a/nsroot/ip/info.json b/nsroot/ip/info.json new file mode 100644 index 0000000..9c3865b --- /dev/null +++ b/nsroot/ip/info.json @@ -0,0 +1,5 @@ +{ + "prefix": "ip info", + "body": "echo `curl -s ipinfo.io/${1|ip,city,region,country,loc,postal,org|}`\n", + "description": "public ip information" +} \ No newline at end of file diff --git a/nsroot/ip/public-address.json b/nsroot/ip/public-address.json new file mode 100644 index 0000000..1209826 --- /dev/null +++ b/nsroot/ip/public-address.json @@ -0,0 +1,5 @@ +{ + "prefix": "ip public", + "body": "PUBLIC_IP=`curl -s ${1|bot.whatismyipaddress.com,ident.me,ipecho.net/plain,icanhazip.com,ifconfig.me,api.ipify.org,ipinfo.io/ip|}`\n", + "description": "public ip address" +} \ No newline at end of file diff --git a/nsroot/lang/for-i-j.json b/nsroot/lang/for-i-j.json new file mode 100644 index 0000000..3fb8f01 --- /dev/null +++ b/nsroot/lang/for-i-j.json @@ -0,0 +1,11 @@ +{ + "prefix": "for ij", + "body": [ + "for((i=0;i<${1:n};i++)); do", + "\tfor((j=0;j<${2:m};j++)); do", + "\t\t${0:echo \"\\$i, \\$j\"}", + "\tdone", + "done\n" + ], + "description": "for loop by index" +} \ No newline at end of file diff --git a/nsroot/lang/for-i.json b/nsroot/lang/for-i.json new file mode 100644 index 0000000..24548df --- /dev/null +++ b/nsroot/lang/for-i.json @@ -0,0 +1,9 @@ +{ + "prefix": "for i", + "body": [ + "for((i=0;i<${1:n};i++)); do", + "\t${0:echo \"\\$i\"}", + "done\n" + ], + "description": "for loop by index" +} \ No newline at end of file diff --git a/nsroot/lang/for-in-collection.json b/nsroot/lang/for-in-collection.json new file mode 100644 index 0000000..cb35c40 --- /dev/null +++ b/nsroot/lang/for-in-collection.json @@ -0,0 +1,9 @@ +{ + "prefix": "for in", + "body": [ + "for ${1:item} in {${2:a..z}}; do", + "\techo \"\\$${1:item}\"", + "done\n" + ], + "description": "for loop in collection" +} \ No newline at end of file diff --git a/nsroot/lang/for-in-column.json b/nsroot/lang/for-in-column.json new file mode 100644 index 0000000..0d88359 --- /dev/null +++ b/nsroot/lang/for-in-column.json @@ -0,0 +1,10 @@ +{ + "prefix": "for in column", + "body": [ + "for ${1:col} in `${2:docker images} | awk '{ print ${3:\\$1\":\"\\$2} }'`; do", + "\t${4:echo \"\\$col\" | cut -d ':' -f 1}", + "\t${5:echo \"\\$col\" | cut -d ':' -f 2}", + "done\n" + ], + "description": "for loop in collection" +} \ No newline at end of file diff --git a/nsroot/lang/if-elif-else.json b/nsroot/lang/if-elif-else.json new file mode 100644 index 0000000..cc31aa3 --- /dev/null +++ b/nsroot/lang/if-elif-else.json @@ -0,0 +1,13 @@ +{ + "prefix": "if", + "body": [ + "if [ ${1:condition} ]; then", + "\t${2: # body}", + "elif [ ${3:condition} ]; then", + "\t${4: # body}", + "else", + "\t${5: # body}", + "fi\n" + ], + "description": "if" +} \ No newline at end of file diff --git a/nsroot/lang/if-not.json b/nsroot/lang/if-not.json new file mode 100644 index 0000000..aa34504 --- /dev/null +++ b/nsroot/lang/if-not.json @@ -0,0 +1,5 @@ +{ + "prefix": "iff not", + "body": "[ ${1:condition} ] || ${2:command}\n", + "description": "if condition is false then run command (short circuit)" +} \ No newline at end of file diff --git a/nsroot/lang/if.json b/nsroot/lang/if.json new file mode 100644 index 0000000..b12a654 --- /dev/null +++ b/nsroot/lang/if.json @@ -0,0 +1,5 @@ +{ + "prefix": "iff", + "body": "[ ${1:condition} ] && ${2:command}\n", + "description": "if condition is true then run command (short circuit)" +} \ No newline at end of file diff --git a/nsroot/lang/switch.json b/nsroot/lang/switch.json new file mode 100644 index 0000000..dfe4453 --- /dev/null +++ b/nsroot/lang/switch.json @@ -0,0 +1,17 @@ +{ + "prefix": "switch case", + "body": [ + "case \"\\$${1:item}\" in", + "\t${2:1})", + "\t\t${3:echo \"case 1\"}", + "\t;;", + "\t${4:2|3})", + "\t\t${5:echo \"case 2 or 3\"}", + "\t;;", + "\t*)", + "\t\t${6:echo \"default\"}", + "\t;;", + "esac\n" + ], + "description": "switch case" +} \ No newline at end of file diff --git a/nsroot/lang/until.json b/nsroot/lang/until.json new file mode 100644 index 0000000..995127d --- /dev/null +++ b/nsroot/lang/until.json @@ -0,0 +1,9 @@ +{ + "prefix": "until", + "body": [ + "until [ ${1:condition} ]; do", + "\t${0:# body}", + "done\n" + ], + "description": "until loop" +} \ No newline at end of file diff --git a/nsroot/lang/while.json b/nsroot/lang/while.json new file mode 100644 index 0000000..ad3b409 --- /dev/null +++ b/nsroot/lang/while.json @@ -0,0 +1,9 @@ +{ + "prefix": "while", + "body": [ + "while [ ${1:condition} ]; do", + "\t${0:# body}", + "done\n" + ], + "description": "while loop" +} \ No newline at end of file diff --git a/nsroot/math/add.json b/nsroot/math/add.json new file mode 100644 index 0000000..da4dc04 --- /dev/null +++ b/nsroot/math/add.json @@ -0,0 +1,5 @@ +{ + "prefix": "math +", + "body": "${1:result}=\\$((${2:var1} + ${3:var2}))\n", + "description": "add two variables" +} \ No newline at end of file diff --git a/nsroot/math/const-gamma.json b/nsroot/math/const-gamma.json new file mode 100644 index 0000000..e476d7d --- /dev/null +++ b/nsroot/math/const-gamma.json @@ -0,0 +1,5 @@ +{ + "prefix": "math const 𝛾", + "body": "MATH_GAMMA='0.57721566490153286060651209008240243'\n", + "description": "math Euler-Mascheroni constant" +} \ No newline at end of file diff --git a/nsroot/math/const-napier.json b/nsroot/math/const-napier.json new file mode 100644 index 0000000..20e0c42 --- /dev/null +++ b/nsroot/math/const-napier.json @@ -0,0 +1,5 @@ +{ + "prefix": "math const e", + "body": "MATH_NAPIER='2.71828182845904523536028747135266249'\n", + "description": "math Napier's constant" +} \ No newline at end of file diff --git a/nsroot/math/const-omega.json b/nsroot/math/const-omega.json new file mode 100644 index 0000000..4d045da --- /dev/null +++ b/nsroot/math/const-omega.json @@ -0,0 +1,5 @@ +{ + "prefix": "math const Ω", + "body": "MATH_OMEGA='0.56714329040978387299996866221035554'\n", + "description": "math Omega constant" +} \ No newline at end of file diff --git a/nsroot/math/const-phi.json b/nsroot/math/const-phi.json new file mode 100644 index 0000000..a6e2938 --- /dev/null +++ b/nsroot/math/const-phi.json @@ -0,0 +1,5 @@ +{ + "prefix": "math const ϕ", + "body": "MATH_GOLDEN_RATIO='1.61803398874989484820458683436563811'\n", + "description": "math golden ration constant" +} \ No newline at end of file diff --git a/nsroot/math/const-pi.json b/nsroot/math/const-pi.json new file mode 100644 index 0000000..ddff662 --- /dev/null +++ b/nsroot/math/const-pi.json @@ -0,0 +1,5 @@ +{ + "prefix": "math const π", + "body": "MATH_PI='3.14159265358979323846264338327950288'\n", + "description": "math PI constant" +} \ No newline at end of file diff --git a/nsroot/math/decrement.json b/nsroot/math/decrement.json new file mode 100644 index 0000000..9ec1f7e --- /dev/null +++ b/nsroot/math/decrement.json @@ -0,0 +1,5 @@ +{ + "prefix": "math --", + "body": "((${1|var--,--var|}))\n", + "description": "decrement variable" +} \ No newline at end of file diff --git a/nsroot/math/divide-equal.json b/nsroot/math/divide-equal.json new file mode 100644 index 0000000..770d2f5 --- /dev/null +++ b/nsroot/math/divide-equal.json @@ -0,0 +1,5 @@ +{ + "prefix": "math /=", + "body": "((${1:var1} /= ${2:var2}))\n", + "description": "divide var1 by var2 and assign the result to var1" +} \ No newline at end of file diff --git a/nsroot/math/divide.json b/nsroot/math/divide.json new file mode 100644 index 0000000..21b66cc --- /dev/null +++ b/nsroot/math/divide.json @@ -0,0 +1,5 @@ +{ + "prefix": "math /", + "body": "${1:result}=\\$((${2:var1} / ${3:var2}))\n", + "description": "divide var1 by var2" +} \ No newline at end of file diff --git a/nsroot/math/float.json b/nsroot/math/float.json new file mode 100644 index 0000000..6b523a9 --- /dev/null +++ b/nsroot/math/float.json @@ -0,0 +1,5 @@ +{ + "prefix": "math 0.00", + "body": "${1:result}=`echo \"scale=${2|0,1,2,3,4,5,6,7,8,9|};(${3:\\$var1} ${4|+,-,*,/,^|} ${5:\\$var2})\" | bc`\n", + "description": "math operations with up to scale decimal places precision" +} \ No newline at end of file diff --git a/nsroot/math/increment.json b/nsroot/math/increment.json new file mode 100644 index 0000000..5cf7e36 --- /dev/null +++ b/nsroot/math/increment.json @@ -0,0 +1,5 @@ +{ + "prefix": "math ++", + "body": "((${1|var++,++var|}))\n", + "description": "increment variable" +} \ No newline at end of file diff --git a/nsroot/math/minus-equal.json b/nsroot/math/minus-equal.json new file mode 100644 index 0000000..8dd0844 --- /dev/null +++ b/nsroot/math/minus-equal.json @@ -0,0 +1,5 @@ +{ + "prefix": "math -=", + "body": "((${1:var1} -= ${2:var2}))\n", + "description": "subtract var2 from var1 and assign the result to var1" +} \ No newline at end of file diff --git a/nsroot/math/modulus-equal.json b/nsroot/math/modulus-equal.json new file mode 100644 index 0000000..8911b23 --- /dev/null +++ b/nsroot/math/modulus-equal.json @@ -0,0 +1,5 @@ +{ + "prefix": "math %=", + "body": "((${1:var1} %= ${2:var2}))\n", + "description": "divide var1 by var2 and assign the reminder to var1" +} \ No newline at end of file diff --git a/nsroot/math/modulus.json b/nsroot/math/modulus.json new file mode 100644 index 0000000..e64a80a --- /dev/null +++ b/nsroot/math/modulus.json @@ -0,0 +1,5 @@ +{ + "prefix": "math %", + "body": "${1:result}=\\$((${2:var1} % ${3:var2}))\n", + "description": "reminder of dividing var1 by var2 (modulus)" +} \ No newline at end of file diff --git a/nsroot/math/multiply-equal.json b/nsroot/math/multiply-equal.json new file mode 100644 index 0000000..9cc2f85 --- /dev/null +++ b/nsroot/math/multiply-equal.json @@ -0,0 +1,5 @@ +{ + "prefix": "math *=", + "body": "((${1:var1} *= ${2:var2}))\n", + "description": "multiply var1 by var2 and assign the result to var1" +} \ No newline at end of file diff --git a/nsroot/math/multiply.json b/nsroot/math/multiply.json new file mode 100644 index 0000000..f82b9f4 --- /dev/null +++ b/nsroot/math/multiply.json @@ -0,0 +1,5 @@ +{ + "prefix": "math *", + "body": "${1:result}=\\$((${2:var1} * ${3:var2}))\n", + "description": "multiply var1 by var2" +} \ No newline at end of file diff --git a/nsroot/math/plus-equal.json b/nsroot/math/plus-equal.json new file mode 100644 index 0000000..cabf546 --- /dev/null +++ b/nsroot/math/plus-equal.json @@ -0,0 +1,5 @@ +{ + "prefix": "math +=", + "body": "((${1:var1} += ${2:var2}))\n", + "description": "add var1 and var2 and assign the result to var1" +} \ No newline at end of file diff --git a/nsroot/math/power.json b/nsroot/math/power.json new file mode 100644 index 0000000..9812ae6 --- /dev/null +++ b/nsroot/math/power.json @@ -0,0 +1,5 @@ +{ + "prefix": "math ^", + "body": "${1:result}=\\$((${2:base} ** ${3:power}))\n", + "description": "exponentiate base to power" +} \ No newline at end of file diff --git a/nsroot/math/random-number.json b/nsroot/math/random-number.json new file mode 100644 index 0000000..b2d3609 --- /dev/null +++ b/nsroot/math/random-number.json @@ -0,0 +1,5 @@ +{ + "prefix": "math random", + "body": "${1:result}=\\$((${2:min} + RANDOM % \\$((${3:max}-${2:min}))))\n", + "description": "generate random integer x such as min <= x <= max" +} \ No newline at end of file diff --git a/nsroot/math/sqrt.json b/nsroot/math/sqrt.json new file mode 100644 index 0000000..1838403 --- /dev/null +++ b/nsroot/math/sqrt.json @@ -0,0 +1,5 @@ +{ + "prefix": "math √", + "body": "${1:result}=`echo \"scale=${2|0,1,2,3,4,5,6,7,8,9|};sqrt(${3:\\$var})\" | bc`\n", + "description": "square root of var up to scale decimal places" +} \ No newline at end of file diff --git a/nsroot/math/subtract.json b/nsroot/math/subtract.json new file mode 100644 index 0000000..8cc3eb7 --- /dev/null +++ b/nsroot/math/subtract.json @@ -0,0 +1,5 @@ +{ + "prefix": "math -", + "body": "${1:result}=\\$((${2:var1} - ${3:var2}))\n", + "description": "subtract var2 from var1" +} \ No newline at end of file diff --git a/nsroot/misc/arguments-parse.json b/nsroot/misc/arguments-parse.json new file mode 100644 index 0000000..6088e05 --- /dev/null +++ b/nsroot/misc/arguments-parse.json @@ -0,0 +1,27 @@ +{ + "prefix": [ + "argument parsing", + "parse args" + ], + "body": [ + "POSITIONAL=()", + "while [[ \\$# > 0 ]]; do", + "\tcase \"\\$1\" in", + "\t\t-f|--flag)", + "\t\techo flag: \\$1", + "\t\tshift # shift once since flags have no values", + "\t\t;;", + "\t\t-s|--switch)", + "\t\techo switch \\$1 with value: \\$2", + "\t\tshift 2 # shift twice to bypass switch and its value", + "\t\t;;", + "\t\t*) # unknown flag/switch", + "\t\tPOSITIONAL+=(\"\\$1\")", + "\t\tshift", + "\t\t;;", + "\tesac", + "done\n", + "set -- \"\\${POSITIONAL[@]}\" # restore positional params\n" + ], + "description": "parse command line arguments (flags/switches)" +} \ No newline at end of file diff --git a/nsroot/misc/expr.json b/nsroot/misc/expr.json new file mode 100644 index 0000000..80d9a7d --- /dev/null +++ b/nsroot/misc/expr.json @@ -0,0 +1,5 @@ +{ + "prefix": "expr", + "body": "expr ${1:2} ${2|+,-,\\*,/,%|} ${3:3}\n", + "description": "arithmetic operations" +} \ No newline at end of file diff --git a/nsroot/misc/let.json b/nsroot/misc/let.json new file mode 100644 index 0000000..0c8c248 --- /dev/null +++ b/nsroot/misc/let.json @@ -0,0 +1,5 @@ +{ + "prefix": "let", + "body": "let \"${1:result} = ${2:var1} ${3|+,-,*,/,%|} ${4:var2}\"\n", + "description": "arithmetic operations" +} \ No newline at end of file diff --git a/nsroot/misc/region.json b/nsroot/misc/region.json new file mode 100644 index 0000000..6d14e38 --- /dev/null +++ b/nsroot/misc/region.json @@ -0,0 +1,9 @@ +{ + "prefix": "region", + "body": [ + "# >>>>>>>>>>>>>>>>>>>>>>>> ${1:name} >>>>>>>>>>>>>>>>>>>>>>>>", + "$0", + "# <<<<<<<<<<<<<<<<<<<<<<<< ${1:name} <<<<<<<<<<<<<<<<<<<<<<<<" + ], + "description": "Comment out a special region (i.e. variable declarations" +} \ No newline at end of file diff --git a/nsroot/misc/shebang.json b/nsroot/misc/shebang.json new file mode 100644 index 0000000..90f6a11 --- /dev/null +++ b/nsroot/misc/shebang.json @@ -0,0 +1,8 @@ +{ + "prefix": [ + "bash", + "shebang" + ], + "body": "#!/usr/bin/env ${1|bash,node,perl,php,python,python3,ruby|}\n\n", + "description": "bash shebang" +} \ No newline at end of file diff --git a/nsroot/misc/sleep.json b/nsroot/misc/sleep.json new file mode 100644 index 0000000..b8101f3 --- /dev/null +++ b/nsroot/misc/sleep.json @@ -0,0 +1,5 @@ +{ + "prefix": "sleep", + "body": "sleep ${1:30}${2|s,m,h,d|}\n", + "description": "sleep for a specified amount of time (s: second, m: minute, h: hour, d: day)" +} \ No newline at end of file diff --git a/nsroot/misc/stopwatch-elapsed.json b/nsroot/misc/stopwatch-elapsed.json new file mode 100644 index 0000000..884d527 --- /dev/null +++ b/nsroot/misc/stopwatch-elapsed.json @@ -0,0 +1,10 @@ +{ + "prefix": "stopwatch elapsed", + "body": [ + "STOPWATCH_ELAPSED_TOTAL_SECONDS=$((STOPWATCH_END_TIME - STOPWATCH_START_TIME))", + "STOPWATCH_ELAPSED_MINUTES=$((STOPWATCH_ELAPSED_TOTAL_SECONDS / 60))", + "STOPWATCH_ELAPSED_SECONDS=$((STOPWATCH_ELAPSED_TOTAL_SECONDS % 60))", + "${1:echo elapsed \\$STOPWATCH_ELAPSED_MINUTES minutes and \\$STOPWATCH_ELAPSED_SECONDS seconds}\n" + ], + "description": "elapsed time" +} \ No newline at end of file diff --git a/nsroot/misc/stopwatch-start.json b/nsroot/misc/stopwatch-start.json new file mode 100644 index 0000000..3c780f8 --- /dev/null +++ b/nsroot/misc/stopwatch-start.json @@ -0,0 +1,5 @@ +{ + "prefix": "stopwatch start", + "body": "STOPWATCH_START_TIME=\\$(date +%s)\n", + "description": "start stopwatch" +} \ No newline at end of file diff --git a/nsroot/misc/stopwatch-stop.json b/nsroot/misc/stopwatch-stop.json new file mode 100644 index 0000000..2d9fb3e --- /dev/null +++ b/nsroot/misc/stopwatch-stop.json @@ -0,0 +1,5 @@ +{ + "prefix": "stopwatch stop", + "body": "STOPWATCH_END_TIME=\\$(date +%s)\n", + "description": "stop stopwatch" +} \ No newline at end of file diff --git a/nsroot/misc/summary.json b/nsroot/misc/summary.json new file mode 100644 index 0000000..33f1548 --- /dev/null +++ b/nsroot/misc/summary.json @@ -0,0 +1,11 @@ +{ + "prefix": "summary", + "body": [ + "# Title: ${1:title}", + "# Description: ${2:description}", + "# Author: ${3:author }", + "# Date: ${4:yyyy-mm-dd}", + "# Version: ${5:1.0.0}\n" + ], + "description": "script summary" +} \ No newline at end of file diff --git a/nsroot/misc/timeout.json b/nsroot/misc/timeout.json new file mode 100644 index 0000000..e7c5e54 --- /dev/null +++ b/nsroot/misc/timeout.json @@ -0,0 +1,5 @@ +{ + "prefix": "timeout", + "body": "timeout ${1:seconds} ${2:command}\n", + "description": "Run command within a time frame" +} \ No newline at end of file diff --git a/nsroot/misc/variable-default-value.json b/nsroot/misc/variable-default-value.json new file mode 100644 index 0000000..7d58705 --- /dev/null +++ b/nsroot/misc/variable-default-value.json @@ -0,0 +1,5 @@ +{ + "prefix": "assign if empty", + "body": ": \"\\${${1:variable}:=${2:default}}\"", + "description": "assign default to variable if variable is empty or null" +} \ No newline at end of file diff --git a/nsroot/output/color-black.json b/nsroot/output/color-black.json new file mode 100644 index 0000000..11b9311 --- /dev/null +++ b/nsroot/output/color-black.json @@ -0,0 +1,5 @@ +{ + "prefix": "color black", + "body": "echo `tput setaf 0`${0:black text}`tput sgr0`\n", + "description": "write in black" +} \ No newline at end of file diff --git a/nsroot/output/color-blue.json b/nsroot/output/color-blue.json new file mode 100644 index 0000000..e3b9901 --- /dev/null +++ b/nsroot/output/color-blue.json @@ -0,0 +1,5 @@ +{ + "prefix": "color blue", + "body": "echo `tput setaf 4`${0:blue text}`tput sgr0`\n", + "description": "write in blue" +} \ No newline at end of file diff --git a/nsroot/output/color-cyan.json b/nsroot/output/color-cyan.json new file mode 100644 index 0000000..0df5fac --- /dev/null +++ b/nsroot/output/color-cyan.json @@ -0,0 +1,5 @@ +{ + "prefix": "color cyan", + "body": "echo `tput setaf 6`${0:cyan text}`tput sgr0`\n", + "description": "write in cyan" +} \ No newline at end of file diff --git a/nsroot/output/color-green.json b/nsroot/output/color-green.json new file mode 100644 index 0000000..7c6d90f --- /dev/null +++ b/nsroot/output/color-green.json @@ -0,0 +1,5 @@ +{ + "prefix": "color green", + "body": "echo `tput setaf 2`${0:green text}`tput sgr0`\n", + "description": "write in green" +} \ No newline at end of file diff --git a/nsroot/output/color-magenta.json b/nsroot/output/color-magenta.json new file mode 100644 index 0000000..0bd4cca --- /dev/null +++ b/nsroot/output/color-magenta.json @@ -0,0 +1,5 @@ +{ + "prefix": "color magenta", + "body": "echo `tput setaf 5`${0:magenta text}`tput sgr0`\n", + "description": "write in magenta" +} \ No newline at end of file diff --git a/nsroot/output/color-red.json b/nsroot/output/color-red.json new file mode 100644 index 0000000..7342bf1 --- /dev/null +++ b/nsroot/output/color-red.json @@ -0,0 +1,5 @@ +{ + "prefix": "color red", + "body": "echo `tput setaf 1`${0:red text}`tput sgr0`\n", + "description": "write in red" +} \ No newline at end of file diff --git a/nsroot/output/color-white.json b/nsroot/output/color-white.json new file mode 100644 index 0000000..7eb74cf --- /dev/null +++ b/nsroot/output/color-white.json @@ -0,0 +1,5 @@ +{ + "prefix": "color white", + "body": "echo `tput setaf 7`${0:white text}`tput sgr0`\n", + "description": "write in white" +} \ No newline at end of file diff --git a/nsroot/output/color-yellow.json b/nsroot/output/color-yellow.json new file mode 100644 index 0000000..92583c1 --- /dev/null +++ b/nsroot/output/color-yellow.json @@ -0,0 +1,5 @@ +{ + "prefix": "color yellow", + "body": "echo `tput setaf 3`${0:yellow text}`tput sgr0`\n", + "description": "write in yellow" +} \ No newline at end of file diff --git a/nsroot/output/format-bold.json b/nsroot/output/format-bold.json new file mode 100644 index 0000000..9d0f399 --- /dev/null +++ b/nsroot/output/format-bold.json @@ -0,0 +1,5 @@ +{ + "prefix": "format bold", + "body": "echo `tput bold`${0:bold text}`tput sgr0`\n", + "description": "write in bold" +} \ No newline at end of file diff --git a/nsroot/output/format-dim.json b/nsroot/output/format-dim.json new file mode 100644 index 0000000..96f6315 --- /dev/null +++ b/nsroot/output/format-dim.json @@ -0,0 +1,5 @@ +{ + "prefix": "format dim", + "body": "echo `tput dim`${0:dimmed text}`tput sgr0`\n", + "description": "write in dim" +} \ No newline at end of file diff --git a/nsroot/output/format-italic.json b/nsroot/output/format-italic.json new file mode 100644 index 0000000..2c51532 --- /dev/null +++ b/nsroot/output/format-italic.json @@ -0,0 +1,5 @@ +{ + "prefix": "format italic", + "body": "echo `tput sitm`${0:italic text}`tput sgr0`\n", + "description": "write in italic" +} \ No newline at end of file diff --git a/nsroot/output/format-reverse.json b/nsroot/output/format-reverse.json new file mode 100644 index 0000000..70c2bf9 --- /dev/null +++ b/nsroot/output/format-reverse.json @@ -0,0 +1,5 @@ +{ + "prefix": "format reverse", + "body": "echo `tput rev`${0:reversed text}`tput sgr0`\n", + "description": "write in reverse" +} \ No newline at end of file diff --git a/nsroot/string/contains.json b/nsroot/string/contains.json new file mode 100644 index 0000000..6737245 --- /dev/null +++ b/nsroot/string/contains.json @@ -0,0 +1,12 @@ +{ + "prefix": [ + "string contains", + "if string contains" + ], + "body": [ + "if [[ \"\\$${1:string}\" = *${2:substring}* ]]; then", + "\t${3:# body}", + "fi\n" + ], + "description": "check whether string contains substring" +} \ No newline at end of file diff --git a/nsroot/string/first-index-substring.json b/nsroot/string/first-index-substring.json new file mode 100644 index 0000000..b8ab701 --- /dev/null +++ b/nsroot/string/first-index-substring.json @@ -0,0 +1,8 @@ +{ + "prefix": "string indexOf", + "body": [ + "temp=\\${${1:string}%%\"${2:substring}\"*} && indexOf=`echo \\${${1:string}%%\"${2:substring}\"*} | echo \\${#temp}`", + "${0:# echo \\$indexOf}" + ], + "description": "first index of substring in string" +} \ No newline at end of file diff --git a/nsroot/string/if-empty.json b/nsroot/string/if-empty.json new file mode 100644 index 0000000..b13c623 --- /dev/null +++ b/nsroot/string/if-empty.json @@ -0,0 +1,9 @@ +{ + "prefix": "if string empty", + "body": [ + "if [ -z \"\\$${1:string}\" ]; then", + "\t${2:# body}", + "fi\n" + ], + "description": "if string is empty" +} \ No newline at end of file diff --git a/nsroot/string/if-equal.json b/nsroot/string/if-equal.json new file mode 100644 index 0000000..844a87f --- /dev/null +++ b/nsroot/string/if-equal.json @@ -0,0 +1,12 @@ +{ + "prefix": [ + "if string =", + "string equal" + ], + "body": [ + "if [ \"\\$${1:string1}\" = \"\\$${2:string2}\" ]; then", + "\t${3:# body}", + "fi\n" + ], + "description": "if strings are equal" +} \ No newline at end of file diff --git a/nsroot/string/if-not-empty.json b/nsroot/string/if-not-empty.json new file mode 100644 index 0000000..f000ac9 --- /dev/null +++ b/nsroot/string/if-not-empty.json @@ -0,0 +1,9 @@ +{ + "prefix": "if string not empty", + "body": [ + "if [ -n \"\\$${1:string}\" ]; then", + "\t${2:# body}", + "fi\n" + ], + "description": "if string is not empty" +} \ No newline at end of file diff --git a/nsroot/string/if-not-equal.json b/nsroot/string/if-not-equal.json new file mode 100644 index 0000000..eee79c4 --- /dev/null +++ b/nsroot/string/if-not-equal.json @@ -0,0 +1,12 @@ +{ + "prefix": [ + "if string !=", + "string not equal" + ], + "body": [ + "if [ \"\\$${1:string1}\" != \"\\$${2:string2}\" ]; then", + "\t${3:# body}", + "fi\n" + ], + "description": "if strings are not equal" +} \ No newline at end of file diff --git a/nsroot/string/length.json b/nsroot/string/length.json new file mode 100644 index 0000000..36f7a39 --- /dev/null +++ b/nsroot/string/length.json @@ -0,0 +1,5 @@ +{ + "prefix": "string length", + "body": "length=\\${#${1:variable}}\n", + "description": "length of string in characters" +} \ No newline at end of file diff --git a/nsroot/string/replace.json b/nsroot/string/replace.json new file mode 100644 index 0000000..04a8c41 --- /dev/null +++ b/nsroot/string/replace.json @@ -0,0 +1,5 @@ +{ + "prefix": "string replace", + "body": "${1:replaced}=`echo -e \"\\${${2:var}}\" | sed -e 's/${3:find}/${4:replace}/g'`", + "description": "find all occurrences of a substrings and replace them" +} \ No newline at end of file diff --git a/nsroot/string/reverse.json b/nsroot/string/reverse.json new file mode 100644 index 0000000..6ab79e3 --- /dev/null +++ b/nsroot/string/reverse.json @@ -0,0 +1,5 @@ +{ + "prefix": "string reverse", + "body": "reversed=`echo -e \"\\${${1:var}}\" | rev`", + "description": "reverse string characters" +} \ No newline at end of file diff --git a/nsroot/string/substring-count.json b/nsroot/string/substring-count.json new file mode 100644 index 0000000..7907b8d --- /dev/null +++ b/nsroot/string/substring-count.json @@ -0,0 +1,8 @@ +{ + "prefix": [ + "string substring count", + "string substring frequency" + ], + "body": "frequency=`sed -E 's/(.)/\\1\\n/g' <<<\"${1:string}\" | grep -c \"${2:substring}\"`\n", + "description": "Frequency of a substring in a string (may need character escaping)" +} \ No newline at end of file diff --git a/nsroot/string/substring.json b/nsroot/string/substring.json new file mode 100644 index 0000000..5e98889 --- /dev/null +++ b/nsroot/string/substring.json @@ -0,0 +1,5 @@ +{ + "prefix": "string substring", + "body": "substring=`echo -e \"\\${${1:var}:${2:offset}:${3:length}}\"`\n", + "description": "part of the string from offset with length characters" +} \ No newline at end of file diff --git a/nsroot/string/to-lower.json b/nsroot/string/to-lower.json new file mode 100644 index 0000000..ff27161 --- /dev/null +++ b/nsroot/string/to-lower.json @@ -0,0 +1,5 @@ +{ + "prefix": "string toLower", + "body": "toLower=`echo -e \"\\${${1:var}}\" | tr '[:upper:]' '[:lower:]'`", + "description": "convert string to lowercase" +} \ No newline at end of file diff --git a/nsroot/string/to-upper.json b/nsroot/string/to-upper.json new file mode 100644 index 0000000..43c363d --- /dev/null +++ b/nsroot/string/to-upper.json @@ -0,0 +1,5 @@ +{ + "prefix": "string toUpper", + "body": "toUpper=`echo -e \"\\${${1:var}}\" | tr '[:lower:]' '[:upper:]'`", + "description": "convert string to uppercase" +} \ No newline at end of file diff --git a/nsroot/string/trim-all.json b/nsroot/string/trim-all.json new file mode 100644 index 0000000..0016b67 --- /dev/null +++ b/nsroot/string/trim-all.json @@ -0,0 +1,5 @@ +{ + "prefix": "string trim all", + "body": "${1:trimmed}=`echo -e \"\\${${2:var}}\" | tr -d '[[:space:]]'`", + "description": "remove all white space(s)" +} \ No newline at end of file diff --git a/nsroot/string/trim-left.json b/nsroot/string/trim-left.json new file mode 100644 index 0000000..e6035e0 --- /dev/null +++ b/nsroot/string/trim-left.json @@ -0,0 +1,5 @@ +{ + "prefix": "string trim left", + "body": "${1:trimmed}=`echo -e \"\\${${2:var}}\" | sed -e 's/^[[:space:]]*//'`", + "description": "remove leading white space(s)" +} \ No newline at end of file diff --git a/nsroot/string/trim-right.json b/nsroot/string/trim-right.json new file mode 100644 index 0000000..12195c8 --- /dev/null +++ b/nsroot/string/trim-right.json @@ -0,0 +1,5 @@ +{ + "prefix": "string trim right", + "body": "${1:trimmed}=`echo -e \"\\${${2:var}}\" | sed -e 's/[[:space:]]*$//'`", + "description": "remove trailing white space(s)" +} \ No newline at end of file diff --git a/nsroot/string/trim.json b/nsroot/string/trim.json new file mode 100644 index 0000000..932cb9c --- /dev/null +++ b/nsroot/string/trim.json @@ -0,0 +1,5 @@ +{ + "prefix": "string trim", + "body": "${1:trimmed}=`echo -e \"\\${${2:var}}\" | sed -e 's/^[[:space:]]*//' | sed -e 's/[[:space:]]*\\$//'`", + "description": "remove leading and trailing white space(s)" +} \ No newline at end of file diff --git a/nsroot/system/distro-codename.json b/nsroot/system/distro-codename.json new file mode 100644 index 0000000..cb2c858 --- /dev/null +++ b/nsroot/system/distro-codename.json @@ -0,0 +1,5 @@ +{ + "prefix": "system distro codename", + "body": "lsb_release -c | awk '{print \\$2}'\n", + "description": "OS codename (i.e. xenial)" +} \ No newline at end of file diff --git a/nsroot/system/distro-name.json b/nsroot/system/distro-name.json new file mode 100644 index 0000000..dcd673b --- /dev/null +++ b/nsroot/system/distro-name.json @@ -0,0 +1,5 @@ +{ + "prefix": "system distro name", + "body": "lsb_release -i | awk '{print \\$3}'\n", + "description": "OS ID (i.e. Ubuntu)" +} \ No newline at end of file diff --git a/nsroot/system/distro-version.json b/nsroot/system/distro-version.json new file mode 100644 index 0000000..8d16381 --- /dev/null +++ b/nsroot/system/distro-version.json @@ -0,0 +1,5 @@ +{ + "prefix": "system distro version", + "body": "lsb_release -r | awk '{print \\$2}'\n", + "description": "OS Release (i.e. 16.04)" +} \ No newline at end of file diff --git a/nsroot/system/kernel-name.json b/nsroot/system/kernel-name.json new file mode 100644 index 0000000..8873772 --- /dev/null +++ b/nsroot/system/kernel-name.json @@ -0,0 +1,5 @@ +{ + "prefix": "system kernel name", + "body": "uname -s\n", + "description": "OS kernel name (i.e. Linux)" +} \ No newline at end of file diff --git a/nsroot/system/kernel-release.json b/nsroot/system/kernel-release.json new file mode 100644 index 0000000..2e2c6dd --- /dev/null +++ b/nsroot/system/kernel-release.json @@ -0,0 +1,5 @@ +{ + "prefix": "system kernel release", + "body": "uname -r\n", + "description": "OS kernel release (i.e. 4.4.0-140-generic)" +} \ No newline at end of file diff --git a/nsroot/system/memory-info.json b/nsroot/system/memory-info.json new file mode 100644 index 0000000..c170ed8 --- /dev/null +++ b/nsroot/system/memory-info.json @@ -0,0 +1,5 @@ +{ + "prefix": "system memory info", + "body": "sysMemory${1|MemTotal,MemFree,MemAvailable,Cached,Buffers,Active,Inactive,SwapTotal,SwapFree,SwapCached|}=`cat /proc/meminfo | grep '${1}' | awk '{print \\$2}' | head -n 1`\n", + "description": "System memory information in kilobytes (KB)" +} \ No newline at end of file diff --git a/nsroot/system/process-id.json b/nsroot/system/process-id.json new file mode 100644 index 0000000..5ae2bf2 --- /dev/null +++ b/nsroot/system/process-id.json @@ -0,0 +1,5 @@ +{ + "prefix": "process ID", + "body": "pgrep ${1:process_name}\n", + "description": "Find process id (PID)" +} \ No newline at end of file diff --git a/nsroot/system/process-kill.json b/nsroot/system/process-kill.json new file mode 100644 index 0000000..9ecf837 --- /dev/null +++ b/nsroot/system/process-kill.json @@ -0,0 +1,5 @@ +{ + "prefix": "process kill", + "body": "sudo kill -9 `pgrep ${1:process_name}`\n", + "description": "Kill process by name" +} \ No newline at end of file diff --git a/nsroot/system/process-list.json b/nsroot/system/process-list.json new file mode 100644 index 0000000..bf80fc7 --- /dev/null +++ b/nsroot/system/process-list.json @@ -0,0 +1,5 @@ +{ + "prefix": "process list", + "body": "ps -A\n", + "description": "List processes" +} \ No newline at end of file diff --git a/nsroot/system/processor-architecture.json b/nsroot/system/processor-architecture.json new file mode 100644 index 0000000..41e4ea2 --- /dev/null +++ b/nsroot/system/processor-architecture.json @@ -0,0 +1,5 @@ +{ + "prefix": "system processor architecture", + "body": "lscpu | grep 'Architecture' |awk '{print \\$2}' | head -n 1\n", + "description": "Processor architecture (i.e. x86_64)" +} \ No newline at end of file diff --git a/nsroot/system/processor-count.json b/nsroot/system/processor-count.json new file mode 100644 index 0000000..146a74f --- /dev/null +++ b/nsroot/system/processor-count.json @@ -0,0 +1,5 @@ +{ + "prefix": "system processor count", + "body": "lscpu | grep 'CPU(s)' |awk '{print \\$2}' | head -n 1\n", + "description": "Processor count (cores)" +} \ No newline at end of file diff --git a/nsroot/system/processor-model.json b/nsroot/system/processor-model.json new file mode 100644 index 0000000..7e2e7ee --- /dev/null +++ b/nsroot/system/processor-model.json @@ -0,0 +1,5 @@ +{ + "prefix": "system processor model", + "body": "lscpu | grep 'Model name' |cut -d ' ' -f 3- | sed -e 's/^[[:space:]]*//'\n", + "description": "Processor model name (i.e. Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz)" +} \ No newline at end of file diff --git a/nsroot/system/processor-type.json b/nsroot/system/processor-type.json new file mode 100644 index 0000000..ffb433c --- /dev/null +++ b/nsroot/system/processor-type.json @@ -0,0 +1,5 @@ +{ + "prefix": "system processor type", + "body": "uname -p\n", + "description": "OS processor type (i.e. x86_64)" +} \ No newline at end of file diff --git a/nsroot/system/service-manage.json b/nsroot/system/service-manage.json new file mode 100644 index 0000000..ec489de --- /dev/null +++ b/nsroot/system/service-manage.json @@ -0,0 +1,5 @@ +{ + "prefix": "service manage", + "body": "sudo systemctl ${1|enable,disable,start,stop,reload,restart,status|} ${2:service}\n", + "description": "Manage service operations" +} \ No newline at end of file diff --git a/nsroot/system/uptime.json b/nsroot/system/uptime.json new file mode 100644 index 0000000..4abce57 --- /dev/null +++ b/nsroot/system/uptime.json @@ -0,0 +1,5 @@ +{ + "prefix": "system uptime", + "body": "sys_uptime=`uptime | cut -d ' ' -f2`\n", + "description": "System uptime (hh:mm:ss)" +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index ddcf9c7..1637ae5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,22 +6,28 @@ "dependencies": { "ansi-styles": { "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { "color-convert": "^1.9.0" } }, + "at-least-node": { + "version": "1.0.0", + "resolved": "http://localhost:8081/repository/npm-registry/at-least-node/-/at-least-node-1.0.0.tgz", + "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", + "dev": true + }, "balanced-match": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, "brace-expansion": { "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { @@ -31,7 +37,7 @@ }, "braces": { "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/braces/-/braces-3.0.2.tgz", "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", "dev": true, "requires": { @@ -40,7 +46,7 @@ }, "chalk": { "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/chalk/-/chalk-2.4.2.tgz", "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "dev": true, "requires": { @@ -51,7 +57,7 @@ }, "color-convert": { "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "dev": true, "requires": { @@ -60,38 +66,41 @@ }, "color-name": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/color-name/-/color-name-1.1.3.tgz", "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, "commander": { "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/commander/-/commander-2.20.3.tgz", "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "dev": true }, "comment-json": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/comment-json/-/comment-json-1.1.3.tgz", - "integrity": "sha1-aYbDMw/uDEyeAMI5jNYa+l2PI54=", + "version": "3.0.2", + "resolved": "http://localhost:8081/repository/npm-registry/comment-json/-/comment-json-3.0.2.tgz", + "integrity": "sha512-ysJasbJ671+8mPEmwLOfLFqxoGtSmjyoep+lKRVH4J1/hsGu79fwetMDQWk8de8mVgqDZ43D7JuJAlACqjI1pg==", "dev": true, "requires": { - "json-parser": "^1.0.0" + "core-util-is": "^1.0.2", + "esprima": "^4.0.1", + "has-own-prop": "^2.0.0", + "repeat-string": "^1.6.1" } }, "concat-map": { "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, "configstore": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/configstore/-/configstore-5.0.0.tgz", - "integrity": "sha512-eE/hvMs7qw7DlcB5JPRnthmrITuHMmACUJAp89v6PT6iOqzoLS7HRWhBtuHMlhNHo2AhUSA/3Dh1bKNJHcublQ==", + "version": "5.0.1", + "resolved": "http://localhost:8081/repository/npm-registry/configstore/-/configstore-5.0.1.tgz", + "integrity": "sha512-aMKprgk5YhBNyH25hj8wGt2+D52Sw1DRRIzqBwLp2Ya9mFmY8KPvvtvmna8SxVR9JMZ4kzMD68N22vlaRpkeFA==", "dev": true, "requires": { - "dot-prop": "^5.1.0", + "dot-prop": "^5.2.0", "graceful-fs": "^4.1.2", "make-dir": "^3.0.0", "unique-string": "^2.0.0", @@ -99,33 +108,48 @@ "xdg-basedir": "^4.0.0" } }, + "core-util-is": { + "version": "1.0.2", + "resolved": "http://localhost:8081/repository/npm-registry/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, "crypto-random-string": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/crypto-random-string/-/crypto-random-string-2.0.0.tgz", "integrity": "sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA==", "dev": true }, "cspell": { - "version": "4.0.46", - "resolved": "https://registry.npmjs.org/cspell/-/cspell-4.0.46.tgz", - "integrity": "sha512-1OzY2LGMQmuoe4odLhabDAxQoPMMwYPCGFKSiJXPJIg+w50iSBpUy2fWu4ExLeMjIUt6jOZ9hTQsq6WRMyXq3g==", + "version": "4.0.63", + "resolved": "http://localhost:8081/repository/npm-registry/cspell/-/cspell-4.0.63.tgz", + "integrity": "sha512-dF0oq69CrTFArISxKhih5p8Mcb1RihzQcQ5LnQnuY66Df/qtyScCMvPgg+G/gUtLPa2RYb3WSy8surZNVS2c0Q==", "dev": true, "requires": { "chalk": "^2.4.2", "commander": "^2.20.3", - "comment-json": "^1.1.3", - "cspell-glob": "^0.1.17", - "cspell-lib": "^4.1.14", - "fs-extra": "^8.1.0", - "gensequence": "^3.0.3", + "comment-json": "^3.0.2", + "cspell-glob": "^0.1.19", + "cspell-lib": "^4.1.29", + "fs-extra": "^9.0.0", + "gensequence": "^3.1.1", "get-stdin": "^7.0.0", "glob": "^7.1.6", "minimatch": "^3.0.4" } }, + "cspell-dict-aws": { + "version": "1.0.5", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-aws/-/cspell-dict-aws-1.0.5.tgz", + "integrity": "sha512-yhOi7YiPuMS+2YPZgZmmwU4U3YPUxF+2TypYXF7eoIjzpNdKrag7r6B2i9lgSttCj6I1oWdjIEmNsAap4Affkw==", + "dev": true, + "requires": { + "configstore": "^5.0.0" + } + }, "cspell-dict-bash": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/cspell-dict-bash/-/cspell-dict-bash-1.0.3.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-bash/-/cspell-dict-bash-1.0.3.tgz", "integrity": "sha512-pEGuoZXhgqhpmmvdEoNY/XYDrypI37y0Z09VgKTHEblzTHo++vLyd4Z8r1SY3kJ2eQejduz4IL7ZGXqgtEp2vw==", "dev": true, "requires": { @@ -133,9 +157,9 @@ } }, "cspell-dict-companies": { - "version": "1.0.20", - "resolved": "https://registry.npmjs.org/cspell-dict-companies/-/cspell-dict-companies-1.0.20.tgz", - "integrity": "sha512-LpDV5YMNV0vG8/LA4S8bbHNwaxI3gHTsCe0XZSGMRFlxO3bWWhi3Il3KB3pdDArDaopTGZKCMXDQsYFy5WHhQA==", + "version": "1.0.22", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-companies/-/cspell-dict-companies-1.0.22.tgz", + "integrity": "sha512-P7ziSCteONYjlPHFFqZTnisSEJr9h9FXTJh0t9QQIoKcaNR4wij5GiZDv4p4YubCf0z3GeJ7Uao+99RGeHakRQ==", "dev": true, "requires": { "configstore": "^5.0.0" @@ -143,17 +167,26 @@ }, "cspell-dict-cpp": { "version": "1.1.26", - "resolved": "https://registry.npmjs.org/cspell-dict-cpp/-/cspell-dict-cpp-1.1.26.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-cpp/-/cspell-dict-cpp-1.1.26.tgz", "integrity": "sha512-ywY7X6UzC5BC7fQhyRAwZHurl52GjwnY6D2wG57JJ/bcT5IsJOWpLAjHORtUH2AcCp6BSAKR6wxl6/bqSuKHJw==", "dev": true, "requires": { "configstore": "^5.0.0" } }, + "cspell-dict-cryptocurrencies": { + "version": "1.0.2", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-cryptocurrencies/-/cspell-dict-cryptocurrencies-1.0.2.tgz", + "integrity": "sha512-suLIsOGmeHt+lqRBbbOJM9aVeBNcXq+3kKINOyuFiAJFpRhDMQrnATzGmW0hhi8XaJHFBcSeQY7iQYe3u1WbnA==", + "dev": true, + "requires": { + "configstore": "^5.0.0" + } + }, "cspell-dict-django": { - "version": "1.0.14", - "resolved": "https://registry.npmjs.org/cspell-dict-django/-/cspell-dict-django-1.0.14.tgz", - "integrity": "sha512-HG/hzldjx2SCOCNP8R4Va3rsiDtOItPhIc6FAKaqp8+6upaCkZmu0QU4RUobbWOyUkZX/WUX5jJRrlj5ZMBjyg==", + "version": "1.0.15", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-django/-/cspell-dict-django-1.0.15.tgz", + "integrity": "sha512-heppo6ZEGgv+cVPDLr24miG8xIn3E5SEGFBGHyNLyGqt8sHzeG3eNKhjKOJCC0hG/fq0ZECbE5q4691LvH24/Q==", "dev": true, "requires": { "configstore": "^5.0.0" @@ -161,7 +194,7 @@ }, "cspell-dict-dotnet": { "version": "1.0.14", - "resolved": "https://registry.npmjs.org/cspell-dict-dotnet/-/cspell-dict-dotnet-1.0.14.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-dotnet/-/cspell-dict-dotnet-1.0.14.tgz", "integrity": "sha512-gTuh94tNAVMS4XmVCK2AsFgKp2mXBk2b8+f2GLCw2K8HY6QUHlvOJg051JJrZABRW/lAoquKZuqssSo9B1mgng==", "dev": true, "requires": { @@ -170,7 +203,7 @@ }, "cspell-dict-elixir": { "version": "1.0.13", - "resolved": "https://registry.npmjs.org/cspell-dict-elixir/-/cspell-dict-elixir-1.0.13.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-elixir/-/cspell-dict-elixir-1.0.13.tgz", "integrity": "sha512-KWDO4NeV3QuMlZxSWpN0sPiFN4GE5AzlDi75eSKRvq/f1+pxgxgXQ5zLNPnDbr2EOSJBV34paZwI+7PvCiTTgA==", "dev": true, "requires": { @@ -179,7 +212,7 @@ }, "cspell-dict-en-gb": { "version": "1.1.16", - "resolved": "https://registry.npmjs.org/cspell-dict-en-gb/-/cspell-dict-en-gb-1.1.16.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-en-gb/-/cspell-dict-en-gb-1.1.16.tgz", "integrity": "sha512-PBzHF40fVj+6Adm3dV3/uhkE2Ptu8W+WJ28socBDDpEfedFMwnC0rpxvAgmKJlLc0OYsn07/yzRnt9srisNrLg==", "dev": true, "requires": { @@ -187,9 +220,9 @@ } }, "cspell-dict-en_us": { - "version": "1.2.24", - "resolved": "https://registry.npmjs.org/cspell-dict-en_us/-/cspell-dict-en_us-1.2.24.tgz", - "integrity": "sha512-EINpnko8JlKGod64Sx5JYZHmUH1rNYaE90ALgqlnWins/t2MEi3ma5u0I7Ghh+/RiNRlcNErrVJxYb2xpeqiJg==", + "version": "1.2.26", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-en_us/-/cspell-dict-en_us-1.2.26.tgz", + "integrity": "sha512-v/9yHpi4J8KAThUa1mtGfhUsv8GXB5lZnKae7ZDN4pzjx5O+KgzZ6GGEUvRlMVzBOl0vEmNInTSIKTG1Y3h4lg==", "dev": true, "requires": { "configstore": "^5.0.0" @@ -197,7 +230,7 @@ }, "cspell-dict-fonts": { "version": "1.0.5", - "resolved": "https://registry.npmjs.org/cspell-dict-fonts/-/cspell-dict-fonts-1.0.5.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-fonts/-/cspell-dict-fonts-1.0.5.tgz", "integrity": "sha512-R9A/MVDzqEQbwXaZhmNJ7bSzzkH5YSJ5UDr3wDRk7FXzNNcuJ4J9WRbkDjCDnoVfg0kCx0FeEp0fme+PbLTeng==", "dev": true, "requires": { @@ -205,9 +238,9 @@ } }, "cspell-dict-fullstack": { - "version": "1.0.22", - "resolved": "https://registry.npmjs.org/cspell-dict-fullstack/-/cspell-dict-fullstack-1.0.22.tgz", - "integrity": "sha512-k8Op1ltkgKnMTTo/kgkywE0htwi+3EtYrPPWk+mD9o3IFgC6yLKA89Tkrd0kEEPR3qJvC4gQJmGJns6Y25v0Zg==", + "version": "1.0.23", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-fullstack/-/cspell-dict-fullstack-1.0.23.tgz", + "integrity": "sha512-vc/aihpKVD/ML+SLVry6kDWFswW/sQfP9QHrr2ZhQLUwhj9pVMnZvx+u1cV8bhMYltWQZxrDhdAe4jrlBrxLHA==", "dev": true, "requires": { "configstore": "^5.0.0" @@ -215,7 +248,7 @@ }, "cspell-dict-golang": { "version": "1.1.14", - "resolved": "https://registry.npmjs.org/cspell-dict-golang/-/cspell-dict-golang-1.1.14.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-golang/-/cspell-dict-golang-1.1.14.tgz", "integrity": "sha512-V9TQQjoTgdLTpLNczEjoF+BO+CkdmuZlD6J71SCT8sczSP0FLz4QkL1MpqiL0lhdnbtASsjs+oCF53Y+dWdh9g==", "dev": true, "requires": { @@ -224,7 +257,7 @@ }, "cspell-dict-haskell": { "version": "1.0.4", - "resolved": "https://registry.npmjs.org/cspell-dict-haskell/-/cspell-dict-haskell-1.0.4.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-haskell/-/cspell-dict-haskell-1.0.4.tgz", "integrity": "sha512-Wy5EE446icPbsi8bLqSCOtxS5Z6QDLGNBvz6Nh+yvuLf7Nb8mU6NQmfSYH/yMfJoVGa5bpcmv8pQtJV4I2E5Tg==", "dev": true, "requires": { @@ -233,7 +266,7 @@ }, "cspell-dict-html-symbol-entities": { "version": "1.0.13", - "resolved": "https://registry.npmjs.org/cspell-dict-html-symbol-entities/-/cspell-dict-html-symbol-entities-1.0.13.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-html-symbol-entities/-/cspell-dict-html-symbol-entities-1.0.13.tgz", "integrity": "sha512-u8BARt4r5rdUee7Yw6ejsD69WLib9l+pyBr4UUIZovhCUccddm2LkS9GDJUqWtCf/frZpoTnmpuW/NPWVVG6pQ==", "dev": true, "requires": { @@ -242,7 +275,7 @@ }, "cspell-dict-java": { "version": "1.0.12", - "resolved": "https://registry.npmjs.org/cspell-dict-java/-/cspell-dict-java-1.0.12.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-java/-/cspell-dict-java-1.0.12.tgz", "integrity": "sha512-9pg5IrCEZGlWLgv8qGjxzzca19egfBYrbnuiWhJNLbBGBOTWrwYjFqbLQtMJReXUtWikWLY0KCzRZlCGusr7bw==", "dev": true, "requires": { @@ -251,7 +284,7 @@ }, "cspell-dict-latex": { "version": "1.0.13", - "resolved": "https://registry.npmjs.org/cspell-dict-latex/-/cspell-dict-latex-1.0.13.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-latex/-/cspell-dict-latex-1.0.13.tgz", "integrity": "sha512-UZqGJQ82mkzseqdF7kWXIrA07VD91W7rWx16DCThDBMohOsFdvCymUUgr0pM90FuqmldSiD+Gi1FayDSyPdNtQ==", "dev": true, "requires": { @@ -260,16 +293,25 @@ }, "cspell-dict-lorem-ipsum": { "version": "1.0.10", - "resolved": "https://registry.npmjs.org/cspell-dict-lorem-ipsum/-/cspell-dict-lorem-ipsum-1.0.10.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-lorem-ipsum/-/cspell-dict-lorem-ipsum-1.0.10.tgz", "integrity": "sha512-UlboQ3xH+D3l+hemLO4J5yz8EM60SH91f1dJIy2s94AeePZXtwYh1hTFM5dEsXI2CAQkfTu3ZdPWflLsInPfrA==", "dev": true, "requires": { "configstore": "^5.0.0" } }, + "cspell-dict-lua": { + "version": "1.0.8", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-lua/-/cspell-dict-lua-1.0.8.tgz", + "integrity": "sha512-zPQoZxcKRbtO7dpWh02zO5kCElzJIqkgjAV209q03k7NoS1n0kAcV48W0agY6T1OR0ZjDWMkUheaLFDbaMJq3g==", + "dev": true, + "requires": { + "configstore": "^5.0.0" + } + }, "cspell-dict-php": { "version": "1.0.13", - "resolved": "https://registry.npmjs.org/cspell-dict-php/-/cspell-dict-php-1.0.13.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-php/-/cspell-dict-php-1.0.13.tgz", "integrity": "sha512-RP5XST+hWEqWxlLISS3sXxsQa2YXOWx8X5LcxQHvEGdb1hMNypXxw9V53th7S+hfUTPKJrbUIzckYZp4j8TS4A==", "dev": true, "requires": { @@ -277,18 +319,18 @@ } }, "cspell-dict-powershell": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/cspell-dict-powershell/-/cspell-dict-powershell-1.0.5.tgz", - "integrity": "sha512-vO4rdojQsmNHvzPdJT/rU2xw03uzs1x7+JJijufDSR+vf277KeQHCUV4+YTm4U7/33XDcPEgYJPT7uhzyjOqmA==", + "version": "1.0.6", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-powershell/-/cspell-dict-powershell-1.0.6.tgz", + "integrity": "sha512-rwxt/fG3Nr7tQaV7e38ilz8qWfXrf5Ie+MQC6Mw/ddjT4wLOkGvruUqtJA/USoDE9PFG12KoarFsWlVXv/nwPA==", "dev": true, "requires": { "configstore": "^5.0.0" } }, "cspell-dict-python": { - "version": "1.0.19", - "resolved": "https://registry.npmjs.org/cspell-dict-python/-/cspell-dict-python-1.0.19.tgz", - "integrity": "sha512-u1jU+4kNn/ds/Wm+oSNy8ZfR6ebK7otNJnxRKXehJfbWWxTbK+vyJF5MThS4osub7fI1FZKW4nPrPjYWIqDevA==", + "version": "1.0.20", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-python/-/cspell-dict-python-1.0.20.tgz", + "integrity": "sha512-BiV8LnH9YNxvkUbVwTyDpZhOuRjPr8cE+nxpuPDbCHmVJmlLsDlg8MXTcJH8I+OFjoz6YdBX6yqK1bi55Aioow==", "dev": true, "requires": { "configstore": "^5.0.0" @@ -296,7 +338,7 @@ }, "cspell-dict-ruby": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/cspell-dict-ruby/-/cspell-dict-ruby-1.0.3.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-ruby/-/cspell-dict-ruby-1.0.3.tgz", "integrity": "sha512-uFxUyGj9SRASfnd75lcpkoNvMYHNWmqkFmS9ZruL61M1RmFx9eekuEY74nK11qsb/E4o6yPtGAQH4SrotF9SwQ==", "dev": true, "requires": { @@ -305,7 +347,7 @@ }, "cspell-dict-rust": { "version": "1.0.12", - "resolved": "https://registry.npmjs.org/cspell-dict-rust/-/cspell-dict-rust-1.0.12.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-rust/-/cspell-dict-rust-1.0.12.tgz", "integrity": "sha512-bMt70/aQL2OcadZRtWfPIF/mHWX9JNOGq92UUU2ka+9C3OPBP/TuyYiHhUWt67y/CoIyEQ7/5uAtjX8paLf14w==", "dev": true, "requires": { @@ -314,7 +356,7 @@ }, "cspell-dict-scala": { "version": "1.0.11", - "resolved": "https://registry.npmjs.org/cspell-dict-scala/-/cspell-dict-scala-1.0.11.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-scala/-/cspell-dict-scala-1.0.11.tgz", "integrity": "sha512-bmAQjapvcceJaiwGTkBd9n2L9GaqpmFDKe5S19WQDsWqjFiDwQ+r47td3TU7yWjOLPqp72h9X/XGzDJFvQEPcg==", "dev": true, "requires": { @@ -322,36 +364,36 @@ } }, "cspell-dict-software-terms": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/cspell-dict-software-terms/-/cspell-dict-software-terms-1.0.5.tgz", - "integrity": "sha512-sFkij2gLxml+yDJZYoUCgj/iaWG8rXOfKzQYE2ON3kA9N+x2xfO1nGOEMukkoRggRhXee1TWV0bJ6Wqekl/Clg==", + "version": "1.0.10", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-software-terms/-/cspell-dict-software-terms-1.0.10.tgz", + "integrity": "sha512-buww9OWunaLwRBiJ+gHW7DLoqMtSbHR6sP3DkvjSZBeke3KxAyS2HmsXPTPVrHFrbqm6qCDmGBs442HZcUz3Iw==", "dev": true, "requires": { "configstore": "^5.0.0" } }, "cspell-dict-typescript": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/cspell-dict-typescript/-/cspell-dict-typescript-1.0.3.tgz", - "integrity": "sha512-j6sVvLUuPCTw5Iqc1D1zB3mWJQTMNshEOmChJfz8vFeBMbu7oj61rLbnhnn2x8kXguKmWN5jhhKnsBIp++jRZA==", + "version": "1.0.5", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-typescript/-/cspell-dict-typescript-1.0.5.tgz", + "integrity": "sha512-bp4rf3/N02Q6JJhJyDcmCtzn9L00nRBQaar3uxRR7lHz3JfIPujUpTXpJN+iuhhcBv8jL1bKTd5wCpfRyHSi1g==", "dev": true, "requires": { "configstore": "^5.0.0" } }, "cspell-glob": { - "version": "0.1.17", - "resolved": "https://registry.npmjs.org/cspell-glob/-/cspell-glob-0.1.17.tgz", - "integrity": "sha512-gAiKakWJbHay6cobcJnX1+XhNCFYqR7CJM5GPiEpRZ5RFXYR46fYbkVwTdg3sqbFLErJtghQj/0s5Xa0q9NJpQ==", + "version": "0.1.19", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-glob/-/cspell-glob-0.1.19.tgz", + "integrity": "sha512-mWWXtKZIsbbUcFKscHEHc2o3fG7VWLqx46ooqbNVnItSZ/jJgPSuguvKh3L6avPY3KKmef2Loae7bjchDwZ+Mw==", "dev": true, "requires": { "micromatch": "^4.0.2" } }, "cspell-io": { - "version": "4.0.20", - "resolved": "https://registry.npmjs.org/cspell-io/-/cspell-io-4.0.20.tgz", - "integrity": "sha512-fomz1P308XgyyxaOEKdNbh82Ac4AKaz26p4JszV7YkJrGDsXMoByTQjVqdDloNN8FchogSEpLPeQoIg648exBA==", + "version": "4.0.22", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-io/-/cspell-io-4.0.22.tgz", + "integrity": "sha512-cjkCHgLZftGPmGe6eSh+FQpQPCxou7t/MjwuCTY8ZeqI55veCF9uCWk8BI4lKbvDjkp6HxgU1T4mighvKY3/wA==", "dev": true, "requires": { "iconv-lite": "^0.4.24", @@ -359,63 +401,67 @@ } }, "cspell-lib": { - "version": "4.1.14", - "resolved": "https://registry.npmjs.org/cspell-lib/-/cspell-lib-4.1.14.tgz", - "integrity": "sha512-K2V7V096c19qOJNPrbAJCVcRHZsyQUISA0eLakIg34nXQlPQZaRdfnXTG5FOFNxyWuub8Ekn8MnDwA54D5AIJw==", + "version": "4.1.29", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-lib/-/cspell-lib-4.1.29.tgz", + "integrity": "sha512-NQTxLhPPObvPg2MJmu1pVJG5fEaytHhhHjHhbdfh6gFTUKdBwQTwxprL+9ySRBPpxm9x7BgqGchJpDa7UbENyQ==", "dev": true, "requires": { - "comment-json": "^1.1.3", - "configstore": "^5.0.0", + "comment-json": "^3.0.2", + "configstore": "^5.0.1", + "cspell-dict-aws": "^1.0.5", "cspell-dict-bash": "^1.0.3", - "cspell-dict-companies": "^1.0.20", + "cspell-dict-companies": "^1.0.22", "cspell-dict-cpp": "^1.1.26", - "cspell-dict-django": "^1.0.14", + "cspell-dict-cryptocurrencies": "^1.0.2", + "cspell-dict-django": "^1.0.15", "cspell-dict-dotnet": "^1.0.14", "cspell-dict-elixir": "^1.0.13", - "cspell-dict-en-gb": "^1.1.14", - "cspell-dict-en_us": "^1.2.23", + "cspell-dict-en-gb": "^1.1.16", + "cspell-dict-en_us": "^1.2.26", "cspell-dict-fonts": "^1.0.5", - "cspell-dict-fullstack": "^1.0.21", + "cspell-dict-fullstack": "^1.0.23", "cspell-dict-golang": "^1.1.14", "cspell-dict-haskell": "^1.0.4", "cspell-dict-html-symbol-entities": "^1.0.13", "cspell-dict-java": "^1.0.12", "cspell-dict-latex": "^1.0.13", "cspell-dict-lorem-ipsum": "^1.0.10", + "cspell-dict-lua": "^1.0.8", "cspell-dict-php": "^1.0.13", - "cspell-dict-powershell": "^1.0.5", - "cspell-dict-python": "^1.0.19", + "cspell-dict-powershell": "^1.0.6", + "cspell-dict-python": "^1.0.20", "cspell-dict-ruby": "^1.0.3", "cspell-dict-rust": "^1.0.12", "cspell-dict-scala": "^1.0.11", - "cspell-dict-software-terms": "^1.0.5", - "cspell-dict-typescript": "^1.0.3", - "cspell-io": "^4.0.20", - "cspell-trie-lib": "^4.1.8", - "cspell-util-bundle": "^4.0.9", - "fs-extra": "^8.1.0", - "gensequence": "^3.0.3", + "cspell-dict-software-terms": "^1.0.10", + "cspell-dict-typescript": "^1.0.5", + "cspell-io": "^4.0.22", + "cspell-trie-lib": "^4.1.10", + "cspell-util-bundle": "^4.0.12", + "fs-extra": "^9.0.0", + "gensequence": "^3.1.1", + "minimatch": "^3.0.4", "vscode-uri": "^2.1.1" } }, "cspell-trie-lib": { - "version": "4.1.8", - "resolved": "https://registry.npmjs.org/cspell-trie-lib/-/cspell-trie-lib-4.1.8.tgz", - "integrity": "sha512-G0Jpybwxyl7rG3c4tzrROEVmiKAsyIjaDdnGxkzOFkl4tjcZeCh7GIVrqLyyk3VWslrWMVvmQi1/eLDccagepw==", + "version": "4.1.10", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-trie-lib/-/cspell-trie-lib-4.1.10.tgz", + "integrity": "sha512-KRcHfdzWQz5W4M4WstzjFDGS8EM7nxGOVXTOq1mNXsT2DkoOemVPI0gIUWLGHcuZuXAj90dkqzEWNk6wZ9v9+w==", "dev": true, "requires": { - "gensequence": "^3.0.3" + "gensequence": "^3.1.1" } }, "cspell-util-bundle": { - "version": "4.0.9", - "resolved": "https://registry.npmjs.org/cspell-util-bundle/-/cspell-util-bundle-4.0.9.tgz", - "integrity": "sha512-+xhIGJAkPxD7aKl97S0E34B5dF+HSTSoEL6M2f6Y46tusFGc9VdhA/iIZQooZZx2RQy4WaHw/ABfsRfxtnFVLw==", + "version": "4.0.12", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-util-bundle/-/cspell-util-bundle-4.0.12.tgz", + "integrity": "sha512-qrqbgSF4Uci/E5q7q95Wd00RrVj6NTABbJGE8qNTMcLfBLezVy0zj+eHdLe7dTkx4oHob2N3WrMBBE3xBhzg/g==", "dev": true }, "dot-prop": { "version": "5.2.0", - "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.2.0.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/dot-prop/-/dot-prop-5.2.0.tgz", "integrity": "sha512-uEUyaDKoSQ1M4Oq8l45hSE26SnTxL6snNnqvK/VWx5wJhmff5z0FUVJDKDanor/6w3kzE3i7XZOk+7wC0EXr1A==", "dev": true, "requires": { @@ -424,19 +470,19 @@ }, "escape-string-regexp": { "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, "esprima": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", - "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=", + "version": "4.0.1", + "resolved": "http://localhost:8081/repository/npm-registry/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true }, "fill-range": { "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/fill-range/-/fill-range-7.0.1.tgz", "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", "dev": true, "requires": { @@ -445,42 +491,43 @@ }, "fs": { "version": "0.0.1-security", - "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/fs/-/fs-0.0.1-security.tgz", "integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ=", "dev": true }, "fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "version": "9.0.0", + "resolved": "http://localhost:8081/repository/npm-registry/fs-extra/-/fs-extra-9.0.0.tgz", + "integrity": "sha512-pmEYSk3vYsG/bF651KPUXZ+hvjpgWYw/Gc7W9NFUe3ZVLczKKWIij3IKpOrQcdw4TILtibFslZ0UmR8Vvzig4g==", "dev": true, "requires": { + "at-least-node": "^1.0.0", "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" + "jsonfile": "^6.0.1", + "universalify": "^1.0.0" } }, "fs.realpath": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, "gensequence": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/gensequence/-/gensequence-3.0.3.tgz", - "integrity": "sha512-KM4L8AfWAfjIvdnBhl7erj35iBNf75pP0+8Ww3BKssVEBv95Dqu40cG62kAyVXtuLplb96wh/GUr+GhM6YG9gQ==", + "version": "3.1.1", + "resolved": "http://localhost:8081/repository/npm-registry/gensequence/-/gensequence-3.1.1.tgz", + "integrity": "sha512-ys3h0hiteRwmY6BsvSttPmkhC0vEQHPJduANBRtH/dlDPZ0UBIb/dXy80IcckXyuQ6LKg+PloRqvGER9IS7F7g==", "dev": true }, "get-stdin": { "version": "7.0.0", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-7.0.0.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/get-stdin/-/get-stdin-7.0.0.tgz", "integrity": "sha512-zRKcywvrXlXsA0v0i9Io4KDRaAw7+a1ZpjRwl9Wox8PFlVCCHra7E9c4kqXCoCM9nR5tBkaTTZRBoCm60bFqTQ==", "dev": true }, "glob": { "version": "7.1.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/glob/-/glob-7.1.6.tgz", "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", "dev": true, "requires": { @@ -493,20 +540,26 @@ } }, "graceful-fs": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", - "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==", + "version": "4.2.4", + "resolved": "http://localhost:8081/repository/npm-registry/graceful-fs/-/graceful-fs-4.2.4.tgz", + "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", "dev": true }, "has-flag": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, + "has-own-prop": { + "version": "2.0.0", + "resolved": "http://localhost:8081/repository/npm-registry/has-own-prop/-/has-own-prop-2.0.0.tgz", + "integrity": "sha512-Pq0h+hvsVm6dDEa8x82GnLSYHOzNDt7f0ddFa3FqcQlgzEiptPqL+XrOJNavjOzSYiYWIrgeVYYgGlLmnxwilQ==", + "dev": true + }, "iconv-lite": { "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/iconv-lite/-/iconv-lite-0.4.24.tgz", "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "dev": true, "requires": { @@ -515,13 +568,13 @@ }, "imurmurhash": { "version": "0.1.4", - "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/imurmurhash/-/imurmurhash-0.1.4.tgz", "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", "dev": true }, "inflight": { "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "requires": { @@ -531,56 +584,48 @@ }, "inherits": { "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, "is-number": { "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true }, "is-obj": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/is-obj/-/is-obj-2.0.0.tgz", "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==", "dev": true }, "is-typedarray": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", "dev": true }, "iterable-to-stream": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/iterable-to-stream/-/iterable-to-stream-1.0.1.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/iterable-to-stream/-/iterable-to-stream-1.0.1.tgz", "integrity": "sha512-O62gD5ADMUGtJoOoM9U6LQ7i4byPXUNoHJ6mqsmkQJcom331ZJGDApWgDESWyBMEHEJRjtHozgIiTzYo9RU4UA==", "dev": true }, - "json-parser": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/json-parser/-/json-parser-1.1.5.tgz", - "integrity": "sha1-5i7FJh0aal/CDoEqMgdAxtkAVnc=", - "dev": true, - "requires": { - "esprima": "^2.7.0" - } - }, "jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "version": "6.0.1", + "resolved": "http://localhost:8081/repository/npm-registry/jsonfile/-/jsonfile-6.0.1.tgz", + "integrity": "sha512-jR2b5v7d2vIOust+w3wtFKZIfpC2pnRmFAhAC/BuweZFQR8qZzxH1OyrQ10HmdVYiXWkYUqPVsz91cG7EL2FBg==", "dev": true, "requires": { - "graceful-fs": "^4.1.6" + "graceful-fs": "^4.1.6", + "universalify": "^1.0.0" } }, "make-dir": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.0.0.tgz", - "integrity": "sha512-grNJDhb8b1Jm1qeqW5R/O63wUo4UXo2v2HMic6YT9i/HBlF93S8jkMgH7yugvY9ABDShH4VZMn8I+U8+fCNegw==", + "version": "3.1.0", + "resolved": "http://localhost:8081/repository/npm-registry/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", "dev": true, "requires": { "semver": "^6.0.0" @@ -588,7 +633,7 @@ }, "micromatch": { "version": "4.0.2", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/micromatch/-/micromatch-4.0.2.tgz", "integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==", "dev": true, "requires": { @@ -598,7 +643,7 @@ }, "minimatch": { "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { @@ -607,7 +652,7 @@ }, "once": { "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { @@ -616,7 +661,7 @@ }, "path": { "version": "0.12.7", - "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/path/-/path-0.12.7.tgz", "integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=", "dev": true, "requires": { @@ -626,43 +671,49 @@ }, "path-is-absolute": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, "picomatch": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.1.tgz", - "integrity": "sha512-ISBaA8xQNmwELC7eOjqFKMESB2VIqt4PPDD0nsS95b/9dZXvVKOlz9keMSnoGGKcOHXfTvDD6WMaRoSc9UuhRA==", + "version": "2.2.2", + "resolved": "http://localhost:8081/repository/npm-registry/picomatch/-/picomatch-2.2.2.tgz", + "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", "dev": true }, "process": { "version": "0.11.10", - "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/process/-/process-0.11.10.tgz", "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", "dev": true }, + "repeat-string": { + "version": "1.6.1", + "resolved": "http://localhost:8081/repository/npm-registry/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, "safer-buffer": { "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, "semver": { "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/semver/-/semver-6.3.0.tgz", "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", "dev": true }, "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "version": "3.0.3", + "resolved": "http://localhost:8081/repository/npm-registry/signal-exit/-/signal-exit-3.0.3.tgz", + "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==", "dev": true }, "supports-color": { "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "dev": true, "requires": { @@ -671,7 +722,7 @@ }, "to-regex-range": { "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "dev": true, "requires": { @@ -680,7 +731,7 @@ }, "typedarray-to-buffer": { "version": "3.1.5", - "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", "dev": true, "requires": { @@ -689,7 +740,7 @@ }, "unique-string": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-2.0.0.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/unique-string/-/unique-string-2.0.0.tgz", "integrity": "sha512-uNaeirEPvpZWSgzwsPGtU2zVSTrn/8L5q/IexZmH0eH6SA73CmAA5U4GwORTxQAZs95TAXLNqeLoPPNO5gZfWg==", "dev": true, "requires": { @@ -697,14 +748,14 @@ } }, "universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "version": "1.0.0", + "resolved": "http://localhost:8081/repository/npm-registry/universalify/-/universalify-1.0.0.tgz", + "integrity": "sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug==", "dev": true }, "util": { "version": "0.10.4", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/util/-/util-0.10.4.tgz", "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", "dev": true, "requires": { @@ -713,7 +764,7 @@ "dependencies": { "inherits": { "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true } @@ -721,20 +772,20 @@ }, "vscode-uri": { "version": "2.1.1", - "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-2.1.1.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/vscode-uri/-/vscode-uri-2.1.1.tgz", "integrity": "sha512-eY9jmGoEnVf8VE8xr5znSah7Qt1P/xsCdErz+g8HYZtJ7bZqKH5E3d+6oVNm1AC/c6IHUDokbmVXKOi4qPAC9A==", "dev": true }, "wrappy": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, "write-file-atomic": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.1.tgz", - "integrity": "sha512-JPStrIyyVJ6oCSz/691fAjFtefZ6q+fP6tm+OS4Qw6o+TGQxNp1ziY2PgS+X/m0V8OWhZiO/m4xSj+Pr4RrZvw==", + "version": "3.0.3", + "resolved": "http://localhost:8081/repository/npm-registry/write-file-atomic/-/write-file-atomic-3.0.3.tgz", + "integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==", "dev": true, "requires": { "imurmurhash": "^0.1.4", @@ -745,7 +796,7 @@ }, "xdg-basedir": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-4.0.0.tgz", + "resolved": "http://localhost:8081/repository/npm-registry/xdg-basedir/-/xdg-basedir-4.0.0.tgz", "integrity": "sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q==", "dev": true } diff --git a/package.json b/package.json index e061def..97dbc92 100644 --- a/package.json +++ b/package.json @@ -29,13 +29,12 @@ ] }, "devDependencies": { - "cspell": "^4.0.46", + "cspell": "^4.0.63", "fs": "0.0.1-security", "path": "^0.12.7" }, "scripts": { - "doc": "node docgen.js", - "clean": "rm COMMANDS.md &> /dev/null", + "build": "node build.js", "spellcheck": "./node_modules/.bin/cspell ./**/*" } -} +} \ No newline at end of file diff --git a/snippets/snippets.json b/snippets/snippets.json index 88469fa..80cc785 100644 --- a/snippets/snippets.json +++ b/snippets/snippets.json @@ -1,1532 +1,1532 @@ { - "bash": { - "prefix": [ - "bash", - "shebang" - ], - "body": "#!/usr/bin/env ${1|bash,node,perl,php,python,python3,ruby|}\n\n", - "description": "bash shebang" - }, - "summary": { - "prefix": "summary", - "body": [ - "# Title: ${1:title}", - "# Description: ${2:description}", - "# Author: ${3:author }", - "# Date: ${4:yyyy-mm-dd}", - "# Version: ${5:1.0.0}\n" - ], - "description": "script summary" - }, - "argument_parsing": { - "prefix": [ - "argument parsing", - "parse args" - ], - "body": [ - "POSITIONAL=()", - "while [[ \\$# > 0 ]]; do", - "\tcase \"\\$1\" in", - "\t\t-f|--flag)", - "\t\techo flag: \\$1", - "\t\tshift # shift once since flags have no values", - "\t\t;;", - "\t\t-s|--switch)", - "\t\techo switch \\$1 with value: \\$2", - "\t\tshift 2 # shift twice to bypass switch and its value", - "\t\t;;", - "\t\t*) # unknown flag/switch", - "\t\tPOSITIONAL+=(\"\\$1\")", - "\t\tshift", - "\t\t;;", - "\tesac", - "done\n", - "set -- \"\\${POSITIONAL[@]}\" # restore positional params\n" - ], - "description": "parse command line arguments (flags/switches)" - }, - "function": { - "prefix": "func", - "body": [ - "function ${1:name} () {", - "\t${2:echo \"\\$1\" # arguments are accessible through $1, $2,...}", - "}\n" - ], - "description": "function" - }, - "function_args_count": { - "prefix": "func args count", - "body": "echo $#", - "description": "number of function arguments" - }, - "function_args": { - "prefix": "func args", - "body": "echo \"$@\"", - "description": "function arguments array" - }, - "function_return_value": { - "prefix": "func ret val", - "body": "echo \"$?\"", - "description": "last function/command return code" - }, - "cmd": { - "prefix": "cmd", - "body": "$(${1:command})\n", - "description": "run command (command substitution)" - }, - "cmd_nice": { - "prefix": "cmd nice", - "body": "sudo nice -n ${1|-20,-15,-10,-5,0,5,10,15,19|} ${0:command}\n", - "description": "run command with desired privilege. n: -20 (highest priority) to 19 (lowest priority)" - }, - "cmd_renice": { - "prefix": "cmd renice", - "body": "for p in \\$(pidof \"${process_name}\"); do sudo renice -n ${1|-20,-15,-10,-5,0,5,10,15,19|} -p \\$p; done", - "description": "Change running process priority. n: -20 (highest priority) to 19 (lowest priority)" - }, - "cmd_success_check": { - "prefix": "cmd success check", - "body": [ - "if [[ \\$? == 0 ]]; then", - "\t${3:echo command succeed}", - "fi\n" - ], - "description": "check if last command succeed" - }, - "cmd_failure_check": { - "prefix": "cmd failure check", - "body": [ - "if [[ \\$? != 0 ]]; then", - "\t${3:echo command failed}", - "fi\n" - ], - "description": "check if last command failed" - }, - "archive_compress_tar_gz": { - "prefix": "archive compress tar.gz", - "body": "tar -czvf ${1:/path/to/archive}.tar.gz ${2:/path/to/directory-or-file}\n", - "description": "compress file/folder to a .tar.gz file" - }, - "archive_decompress_tar_gz": { - "prefix": "archive decompress tar.gz", - "body": "tar -C ${1:/extract/to/path} -xzvf ${2:/path/to/archive}.tar.gz\n", - "description": "decompress a .tar.gz file to specified path" - }, - "array_concat": { - "prefix": "array concat", - "body": "${1:newArray}=(\"${${2:array1}[@]}\" \"${${3:array2}[@]}\")\n", - "description": "concatenate two arrays" - }, - "array_declare": { - "prefix": "array declare", - "body": "${1:myArray}=('${2:one}' '${3:two}' '${4:three}')\n", - "description": "declare an array" - }, - "array_delete": { - "prefix": "array delete", - "body": "unset ${1:myArray}\n", - "description": "delete entire array" - }, - "array_delete_at": { - "prefix": "array delete at", - "body": "unset ${1:myArray}[${2:index}]\n", - "description": "delete element at index from array" - }, - "array_all": { - "prefix": "array all", - "body": "${myArray[@]}\n", - "description": "all array elements" - }, - "array_filter": { - "prefix": "array filter", - "body": "${1:filtered}=(`for i in ${${2:myArray}[@]} ; do echo \\$i; done | grep ${3:pattern}`)\n", - "description": "filter elements of an array based on given pattern" - }, - "array_push": { - "prefix": [ - "array push", - "array add" - ], - "body": "${1:myArray}+=('${2:newItem}')\n", - "description": "push new item to the end of array" - }, - "array_replace": { - "prefix": "array replace", - "body": "${myArray[@]//${1:find}/${2:replace}}\n", - "description": "find and replace elements in array using regex" - }, - "array_at_index": { - "prefix": "array at index", - "body": "${myArray[${1:index}]}\n", - "description": "retrieve element at specified index (zero based)" - }, - "array_iterate": { - "prefix": [ - "array iterate", - "array forEach" - ], - "body": [ - "for item in ${${1:myArray}[@]}; do", - "\t${2:echo \"\\$item\"}", - "done\n" - ], - "description": "iterate array elements" - }, - "array_length": { - "prefix": "array length", - "body": "${#${1:myArray}[@]}\n", - "description": "length of array" - }, - "array_range": { - "prefix": [ - "array slice", - "array range" - ], - "body": "${myArray[@]:${1:from}:${2:count}}\n", - "description": "elements of array from index, equal to count numbers" - }, - "array_set_element": { - "prefix": "array set element", - "body": "myArray[${1:index}]=${2:value}\n", - "description": "set array element at index" - }, - "assign_if_empty": { - "prefix": "assign if empty", - "body": ": \"\\${${1:variable}:=${2:default}}\"", - "description": "assign default to variable if variable is empty or null" - }, - "ask_question": { - "prefix": "ask question", - "body": [ - "read -ep \"${1:Question here? }\" -i ${2:Default answer} ANSWER", - "${3:echo \"\\$ANSWER\"}\n" - ], - "description": "Ask question with default answer" - }, - "crypto_base64_encode": { - "prefix": "crypto base64 encode", - "body": "${1:base64Encoded}=`echo -n \"\\$${2:variableToEncode}\" | base64`\n", - "description": "encode variable to base64" - }, - "crypto_base64_decode": { - "prefix": "crypto base64 decode", - "body": "${1:base64Decoded}=`echo -n \"\\$${2:variableToDecode}\" | base64 -d`\n", - "description": "decode variable from base64" - }, - "crypto_hash": { - "prefix": "crypto hash", - "body": "${1:hash}=`echo -n \"\\$${2:variableToHash}\" | ${3|md5sum,shasum,sha1sum,sha224sum,sha256sum,sha384sum,sha512sum|} | cut -f1 -d ' '`\n", - "description": "compute hash of variable (md5, sha, sha1, sha224, sha256, sha384, sha512)" - }, - "date_short": { - "prefix": "date now short", - "body": "dateShort=`date -I`\n", - "description": "yyyy/mm/dd" - }, - "date_utc": { - "prefix": "date now UTC", - "body": "dateUTC=`date -u`\n", - "description": "coordinated Universal Time" - }, - "date_year": { - "prefix": "date now year", - "body": "year=`date +%Y`\n", - "description": "current Year" - }, - "date_month_number": { - "prefix": "date now monthNumber", - "body": "monthNumber=`date +%m`\n", - "description": "current month number (1..12)" - }, - "date_month_name": { - "prefix": "date now monthName", - "body": "monthName=`date +%${1|B,b|}`\n", - "description": "current month name (full/abbreviated B/b)" - }, - "date_day": { - "prefix": "date now dayOfMonth", - "body": "dayOfMonth=`date +%d`\n", - "description": "current day of month (1..31)" - }, - "date_day_of_week": { - "prefix": "date now dayOfWeek", - "body": "dayOfWeek=`date +%${1|A,a|}`\n", - "description": "current day of week name (full/abbreviated A/a)" - }, - "date_day_of_year": { - "prefix": "date now dayOfYear", - "body": "dayOfYear=`date +%j`\n", - "description": "current day of year (1..366)" - }, - "time_local": { - "prefix": "time now local", - "body": "timeNowLocal=`date +%${1|R,r|}`\n", - "description": "current local time (24hrs/12hrs R/r)" - }, - "time_utc": { - "prefix": "time now UTC", - "body": "timeNowUTC=`date -u +%R`\n", - "description": "current UTC time" - }, - "time_epoch_seconds": { - "prefix": "time seconds epoch", - "body": "timeNowSecondsEpoch=`date +%s`\n", - "description": "seconds since epoch (1970-01-01 00:00:00)" - }, - "directory_create": { - "prefix": "directory create", - "body": "mkdir \"${1:dirname}\"\n", - "description": "create directory" - }, - "directory_create_nested": { - "prefix": "directory create nested", - "body": "mkdir -p \"${1:parent dir}\"/\"${2:child dir}\"\n", - "description": "create nested directories" - }, - "git_branch_list": { - "prefix": "git branch list", - "body": "git branch\n", - "description": "List all branches." - }, - "git_branch_create": { - "prefix": "git branch create", - "body": "git checkout -b ${1:branchName}\n", - "description": "Create branch locally and switch into it." - }, - "git_branch_delete_local": { - "prefix": "git branch delete local", - "body": "git branch --delete ${1:localBranch}\n", - "description": "Delete local branch." - }, - "git_branch_delete_remote": { - "prefix": "git branch delete remote", - "body": "git push origin --delete ${1:remoteBranch}\n", - "description": "Delete remote branch." - }, - "git_branch_push": { - "prefix": "git branch push", - "body": "git push origin ${1:branchName}\n", - "description": "Push branch to remote." - }, - "git_branch_rename": { - "prefix": "git branch rename", - "body": "git branch -m ${1:newName}\n", - "description": "Rename current branch." - }, - "git_changes_revert": { - "prefix": "git changes revert", - "body": "git checkout .\n", - "description": "Revert tracked changes" - }, - "git_clone": { - "prefix": "git clone", - "body": "git clone https://${1:github.com}/${2:user}/${3:repository}.git\n", - "description": "Clone remote repository to local machine." - }, - "git_clone_branch": { - "prefix": "git clone branch", - "body": "git clone -b ${1:branchName} https://${2:github.com}/${3:user}/${4:repository}.git\n", - "description": "Clone a remote branch to local machine." - }, - "git_commit": { - "prefix": "git commit", - "body": "git commit -m \"${1:commit message}\"\n", - "description": "Commit changes." - }, - "git_commit_list": { - "prefix": "git commit list notPushed", - "body": "git log origin/master..HEAD\n", - "description": "List non pushed commits." - }, - "git_commit_search": { - "prefix": "git commit search", - "body": "git log --all --grep='${1:searchCriteria}'\n", - "description": "Search for a commit which contains searchCriteria." - }, - "git_commit_undo": { - "prefix": "git commit undo", - "body": "git reset --${1|soft,hard|} HEAD~${2|1,2,3,4,5|}\n", - "description": "Undo last N commits (soft: preserve local changes | hard: delete local changes" - }, - "git_config_list": { - "prefix": "git config list", - "body": "git config --list\n", - "description": "List git configurations." - }, - "git_config_set": { - "prefix": "git config set", - "body": "git config --${1|local,global|} ${2|user.name,user.email|} \"${3:value}\"\n", - "description": "Configure git." - }, - "git_patch_apply": { - "prefix": "git patch apply", - "body": "git apply < ${0:/path/to/patch1.patch}\n", - "description": "Apply a patch from file." - }, - "git_patch_create": { - "prefix": "git patch create", - "body": "git diff > ${0:/path/to/patch1.patch}\n", - "description": "Create a patch from changes." - }, - "git_remote_list": { - "prefix": "git remote list", - "body": "git remote\n", - "description": "List all remotes." - }, - "git_remote_urlAdd": { - "prefix": "git remote urlAdd", - "body": "git remote add origin https://${1:github.com}/${2:user}/${3:repository}.git\n", - "description": "Add remote url." - }, - "git_remote_urlChange": { - "prefix": "git remote urlChange", - "body": "git remote set-url origin https://${1:github.com}/${2:user}/${3:repository}.git\n", - "description": "Change remote url." - }, - "git_tag_list": { - "prefix": "git tag list", - "body": "git tag\n", - "description": "List all tags." - }, - "git_tag_commit": { - "prefix": [ - "git tag commit", - "git commit tag" - ], - "body": "git tag -a ${1:release/1.0.0} -m \"${2:1.0.0 release}\"\n", - "description": "Tag a commit." - }, - "git_tag_remote_delete": { - "prefix": "git tag remote delete", - "body": "git push --delete origin ${1:tagName} && git push origin :${1:tagName}\n", - "description": "Delete tag from remote." - }, - "git_tag_remote_push": { - "prefix": "git tag remote push", - "body": "git push origin ${1:tagName}\n", - "description": "Push tag to remote." - }, - "http_get": { - "prefix": [ - "http GET", - "http DELETE" - ], - "body": [ - "curl --request ${1|GET,DELETE|} -sL \\", - "\t--user-agent '${2|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \\", - "\t--url '${3:http://example.com}'\n" - ], - "description": "Send http GET/DELETE request using curl" - }, - "http_post": { - "prefix": [ - "http POST", - "http PUT" - ], - "body": [ - "curl --request ${1|POST,PUT|} -sL \\", - "\t--user-agent '${2|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \\", - "\t--url '${3:http://example.com}' \\", - "\t--data '${4:key}=${5:value}' \\", - "\t--data '${6:key}=${7:value}'\n" - ], - "description": "Send data with http POST/PUT, using curl" - }, - "http_post_file": { - "prefix": "http POST file", - "body": [ - "curl --request POST -sL \\", - "\t--user-agent '${1|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \\", - "\t--url '${2:http://example.com}' \\", - "\t--form '${3:key}=${4:value}' \\", - "\t--form 'file=@${5:/path/to/file}'\n" - ], - "description": "Send file with http POST, using curl" - }, - "http_header": { - "prefix": "http header", - "body": [ - "curl --request ${1|GET,POST,DELETE,PUT|} -sL \\", - "\t--user-agent '${2|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \\", - "\t--header '${3:key}: ${4:value}' \\", - "\t--url '${5:http://example.com}'\n" - ], - "description": "Send http request with custom header, using curl" - }, - "http_cookie": { - "prefix": "http cookie", - "body": [ - "curl --request ${1|GET,POST,DELETE,PUT|} -sL \\", - "\t--user-agent '${2|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \\", - "\t--cookie '${3:key}=${4:value}' \\", - "\t--url '${5:http://example.com}'\n" - ], - "description": "Send http request with cookies, using curl" - }, - "http_download": { - "prefix": "http download", - "body": [ - "curl --request ${1|GET,POST|} -sL \\", - "\t--user-agent '${2|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \\", - "\t--output '${3:/path/to/file}' \\", - "\t--url '${4:http://example.com/file.zip}'\n" - ], - "description": "Download from url and save to /path/to/file, using curl" - }, - "ftp_list": { - "prefix": "ftp list", - "body": "curl ftp://${1:user}:${2:password}@${3:ipOrDomain}/${4:directoryPathOnServer}/\n", - "description": "Get the list of files on the ftp server at specific path" - }, - "ftp_download": { - "prefix": "ftp download", - "body": "curl ftp://${1:user}:${2:password}@${3:ipOrDomain}/${4:filePathOnServer}/\n", - "description": "Download specified file from ftp server" - }, - "ftp_upload": { - "prefix": "ftp upload", - "body": "curl -T ${1:fileToUpload} ftp://${2:user}:${3:password}@${4:ipOrDomain}/${5:directoryPathOnServer}/\n", - "description": "Upload specified file to ftp server" - }, - "ftp_delete_file": { - "prefix": "ftp delete file", - "body": "curl ftp://${1:user}:${2:password}@${3:ipOrDomain}/${4:path}/${5:fileToDelete} -Q \"DELE ${5:fileToDelete}\"\n", - "description": "Delete specified file from ftp server" - }, - "ftp_rename": { - "prefix": "ftp rename", - "body": "curl ftp://${1:user}:${2:password}@${3:ipOrDomain}/${4:path}/ -Q \"-RNFR ${4:path}/${5:renameFrom}\" -Q \"-RNTO ${4:path}/${6:renameTo}\"\n", - "description": "Rename specified file/directory on ftp server" - }, - "if": { - "prefix": "if", - "body": [ - "if [ ${1:condition} ]; then", - "\t${2: # body}", - "elif [ ${3:condition} ]; then", - "\t${4: # body}", - "else", - "\t${5: # body}", - "fi\n" - ], - "description": "if" - }, - "iff": { - "prefix": "iff", - "body": "[ ${1:condition} ] && ${2:command}\n", - "description": "if condition is true then run command (short circuit)" - }, - "iff_not": { - "prefix": "iff not", - "body": "[ ${1:condition} ] || ${2:command}\n", - "description": "if condition is false then run command (short circuit)" - }, - "if_string_empty": { - "prefix": "if string empty", - "body": [ - "if [ -z \"\\$${1:string}\" ]; then", - "\t${2:# body}", - "fi\n" - ], - "description": "if string is empty" - }, - "if_string_not_empty": { - "prefix": "if string not empty", - "body": [ - "if [ -n \"\\$${1:string}\" ]; then", - "\t${2:# body}", - "fi\n" - ], - "description": "if string is not empty" - }, - "if_string_equal": { - "prefix": [ - "if string =", - "string equal" - ], - "body": [ - "if [ \"\\$${1:string1}\" = \"\\$${2:string2}\" ]; then", - "\t${3:# body}", - "fi\n" - ], - "description": "if strings are equal" - }, - "if_string_not_equal": { - "prefix": [ - "if string !=", - "string not equal" - ], - "body": [ - "if [ \"\\$${1:string1}\" != \"\\$${2:string2}\" ]; then", - "\t${3:# body}", - "fi\n" - ], - "description": "if strings are not equal" - }, - "string_length": { - "prefix": "string length", - "body": "length=\\${#${1:variable}}\n", - "description": "length of string in characters" - }, - "string_trim": { - "prefix": "string trim", - "body": "${1:trimmed}=`echo -e \"\\${${2:var}}\" | sed -e 's/^[[:space:]]*//' | sed -e 's/[[:space:]]*\\$//'`", - "description": "remove leading and trailing white space(s)" - }, - "string_trim_left": { - "prefix": "string trim left", - "body": "${1:trimmed}=`echo -e \"\\${${2:var}}\" | sed -e 's/^[[:space:]]*//'`", - "description": "remove leading white space(s)" - }, - "string_trim_right": { - "prefix": "string trim right", - "body": "${1:trimmed}=`echo -e \"\\${${2:var}}\" | sed -e 's/[[:space:]]*$//'`", - "description": "remove trailing white space(s)" - }, - "string_trim_all": { - "prefix": "string trim all", - "body": "${1:trimmed}=`echo -e \"\\${${2:var}}\" | tr -d '[[:space:]]'`", - "description": "remove all white space(s)" - }, - "string_replace": { - "prefix": "string replace", - "body": "${1:replaced}=`echo -e \"\\${${2:var}}\" | sed -e 's/${3:find}/${4:replace}/g'`", - "description": "find all occurrences of a substrings and replace them" - }, - "string_reverse": { - "prefix": "string reverse", - "body": "reversed=`echo -e \"\\${${1:var}}\" | rev`", - "description": "reverse string characters" - }, - "string_to_lower": { - "prefix": "string toLower", - "body": "toLower=`echo -e \"\\${${1:var}}\" | tr '[:upper:]' '[:lower:]'`", - "description": "convert string to lowercase" - }, - "string_to_upper": { - "prefix": "string toUpper", - "body": "toUpper=`echo -e \"\\${${1:var}}\" | tr '[:lower:]' '[:upper:]'`", - "description": "convert string to uppercase" - }, - "string_substring": { - "prefix": "string substring", - "body": "substring=`echo -e \"\\${${1:var}:${2:offset}:${3:length}}\"`\n", - "description": "part of the string from offset with length characters" - }, - "string_contains": { - "prefix": [ - "string contains", - "if string contains" - ], - "body": [ - "if [[ \"\\$${1:string}\" = *${2:substring}* ]]; then", - "\t${3:# body}", - "fi\n" - ], - "description": "check whether string contains substring" - }, - "string_substring_count": { - "prefix": [ - "string substring count", - "string substring frequency" - ], - "body": "frequency=`sed -E 's/(.)/\\1\\n/g' <<<\"${1:string}\" | grep -c \"${2:substring}\"`\n", - "description": "Frequency of a substring in a string (may need character escaping)" - }, - "string_index_of": { - "prefix": "string indexOf", - "body": [ - "temp=\\${${1:string}%%\"${2:substring}\"*} && indexOf=`echo \\${${1:string}%%\"${2:substring}\"*} | echo \\${#temp}`", - "${0:# echo \\$indexOf}" - ], - "description": "first index of substring in string" - }, - "if_int_equal": { - "prefix": "if int =", - "body": [ - "if (( ${1:int1} == ${2:int2} )); then", - "\t${3:echo equal}", - "fi\n" - ], - "description": "if integers are equal" - }, - "if_int_not_equal": { - "prefix": "if int !=", - "body": [ - "if (( ${1:int1} != ${2:int2} )); then", - "\t${3:echo not equal}", - "fi\n" - ], - "description": "if integers are not equal" - }, - "if_int_greater": { - "prefix": "if int >", - "body": [ - "if (( ${1:int} > ${2:val} )); then", - "\t${3:echo greater}", - "fi\n" - ], - "description": "if integer greater than value" - }, - "if_int_greater_equal": { - "prefix": "if int >=", - "body": [ - "if (( ${1:int} >= ${2:val} )); then", - "\t${3:echo greater equal}", - "fi\n" - ], - "description": "if integer greater than or equal value" - }, - "if_int_less_than": { - "prefix": "if int <", - "body": [ - "if (( ${1:int} < ${2:val} )); then", - "\t${3:echo lesser}", - "fi\n" - ], - "description": "if integer lesser than value" - }, - "if_int_less_equal": { - "prefix": "if int <=", - "body": [ - "if (( ${1:int} <= ${2:val} )); then", - "\t${3:echo lesser equal}", - "fi\n" - ], - "description": "if integer lesser than or equal value" - }, - "if_cmd_exists": { - "prefix": "if cmd exists", - "body": [ - "if [ `command -v ${1:command}` ]; then", - "\t${2:# body}", - "fi\n" - ], - "description": "check if command exists" - }, - "if_exists": { - "prefix": "if exists", - "body": [ - "if [ -e \"\\$${1:path}\" ]; then", - "\t${0:echo exists}", - "fi\n" - ], - "description": "if path exists (file, directory, link...)" - }, - "if_file_exists": { - "prefix": "if file exists", - "body": [ - "if [ -f \"\\$${1:file}\" ]; then", - "\t${2:echo file exists}", - "fi\n" - ], - "description": "if file exists" - }, - "if_file_not_empty": { - "prefix": "if file not empty", - "body": [ - "if [ -s \"\\$${1:file}\" ]; then", - "\t${2:echo file not empty}", - "fi\n" - ], - "description": "if file size is greater than zero" - }, - "if_directory_exists": { - "prefix": "if directory exists", - "body": [ - "if [ -d \"\\$${1:directory}\" ]; then", - "\t${0:echo directory exists}", - "fi\n" - ], - "description": "if directory exists" - }, - "if_file_readable": { - "prefix": "if file readable", - "body": [ - "if [ -r \"\\$${1:file}\" ]; then", - "\t${0:echo file is readable}", - "fi\n" - ], - "description": "if file readable" - }, - "if_file_writeable": { - "prefix": "if file writeable", - "body": [ - "if [ -w \"\\$${1:file}\" ]; then", - "\t${0:echo file is writeable}", - "fi\n" - ], - "description": "if file writeable" - }, - "if_file_executable": { - "prefix": "if file executable", - "body": [ - "if [ -x \"\\$${1:file}\" ]; then", - "\t${0:echo file is executable}", - "fi\n" - ], - "description": "if file executable" - }, - "if_file_equal": { - "prefix": "if file =", - "body": [ - "if [ \"\\$${1:file1}\" -ef \"\\$${2:file2}\" ]; then", - "\t${0:echo files are equal}", - "fi\n" - ], - "description": "if files are equal" - }, - "if_file_link": { - "prefix": "if file link", - "body": [ - "if [ -h \"\\$${1:file}\" ]; then", - "\t${0:echo symbolic link}", - "fi\n" - ], - "description": "if file exists and is a symbolic link" - }, - "if_file_newer": { - "prefix": "if file newer", - "body": [ - "if [ \"\\$${1:file1}\" -nt \"\\$${2:file2}\" ]; then", - "\t${0:echo file1 is newer than file2}", - "fi\n" - ], - "description": "if file1 newer than file2" - }, - "if_file_older": { - "prefix": "if file older", - "body": [ - "if [ \"\\$${1:file1}\" -ot \"\\$${2:file2}\" ]; then", - "\t${0:echo file1 is older than file2}", - "fi\n" - ], - "description": "if file1 older than file2" - }, - "ips": { - "prefix": "ips", - "body": "IPS=`hostname -I`\n", - "description": "Array of local IPs" - }, - "ip_info": { - "prefix": "ip info", - "body": "echo `curl -s ipinfo.io/${1|ip,city,region,country,loc,postal,org|}`\n", - "description": "public ip information" - }, - "ip_public": { - "prefix": "ip public", - "body": "PUBLIC_IP=`curl -s ${1|bot.whatismyipaddress.com,ident.me,ipecho.net/plain,icanhazip.com,ifconfig.me,api.ipify.org,ipinfo.io/ip|}`\n", - "description": "public ip address" - }, - "for_i": { - "prefix": "for i", - "body": [ - "for((i=0;i<${1:n};i++)); do", - "\t${0:echo \"\\$i\"}", - "done\n" - ], - "description": "for loop by index" - }, - "for_ij": { - "prefix": "for ij", - "body": [ - "for((i=0;i<${1:n};i++)); do", - "\tfor((j=0;j<${2:m};j++)); do", - "\t\t${0:echo \"\\$i, \\$j\"}", - "\tdone", - "done\n" - ], - "description": "for loop by index" - }, - "for_in": { - "prefix": "for in", - "body": [ - "for ${1:item} in {${2:a..z}}; do", - "\techo \"\\$${1:item}\"", - "done\n" - ], - "description": "for loop in collection" - }, - "for_in_column": { - "prefix": "for in column", - "body": [ - "for ${1:col} in `${2:docker images} | awk '{ print ${3:\\$1\":\"\\$2} }'`; do", - "\t${4:echo \"\\$col\" | cut -d ':' -f 1}", - "\t${5:echo \"\\$col\" | cut -d ':' -f 2}", - "done\n" - ], - "description": "for loop in collection" - }, - "while": { - "prefix": "while", - "body": [ - "while [ ${1:condition} ]; do", - "\t${0:# body}", - "done\n" - ], - "description": "while loop" - }, - "until": { - "prefix": "until", - "body": [ - "until [ ${1:condition} ]; do", - "\t${0:# body}", - "done\n" - ], - "description": "until loop" - }, - "switch": { - "prefix": "switch case", - "body": [ - "case \"\\$${1:item}\" in", - "\t${2:1})", - "\t\t${3:echo \"case 1\"}", - "\t;;", - "\t${4:2|3})", - "\t\t${5:echo \"case 2 or 3\"}", - "\t;;", - "\t*)", - "\t\t${6:echo \"default\"}", - "\t;;", - "esac\n" - ], - "description": "switch case" - }, - "let": { - "prefix": "let", - "body": "let \"${1:result} = ${2:var1} ${3|+,-,*,/,%|} ${4:var2}\"\n", - "description": "arithmetic operations" - }, - "expr": { - "prefix": "expr", - "body": "expr ${1:2} ${2|+,-,\\*,/,%|} ${3:3}\n", - "description": "arithmetic operations" - }, - "math_inc": { - "prefix": "math ++", - "body": "((${1|var++,++var|}))\n", - "description": "increment variable" - }, - "math_dec": { - "prefix": "math --", - "body": "((${1|var--,--var|}))\n", - "description": "decrement variable" - }, - "math_add": { - "prefix": "math +", - "body": "${1:result}=\\$((${2:var1} + ${3:var2}))\n", - "description": "add two variables" - }, - "math_plus_equal": { - "prefix": "math +=", - "body": "((${1:var1} += ${2:var2}))\n", - "description": "add var1 and var2 and assign the result to var1" - }, - "math_subtract": { - "prefix": "math -", - "body": "${1:result}=\\$((${2:var1} - ${3:var2}))\n", - "description": "subtract var2 from var1" - }, - "math_minus_equal": { - "prefix": "math -=", - "body": "((${1:var1} -= ${2:var2}))\n", - "description": "subtract var2 from var1 and assign the result to var1" - }, - "math_multiply": { - "prefix": "math *", - "body": "${1:result}=\\$((${2:var1} * ${3:var2}))\n", - "description": "multiply var1 by var2" - }, - "math_multiply_equal": { - "prefix": "math *=", - "body": "((${1:var1} *= ${2:var2}))\n", - "description": "multiply var1 by var2 and assign the result to var1" - }, - "math_divide": { - "prefix": "math /", - "body": "${1:result}=\\$((${2:var1} / ${3:var2}))\n", - "description": "divide var1 by var2" - }, - "math_divide_equal": { - "prefix": "math /=", - "body": "((${1:var1} /= ${2:var2}))\n", - "description": "divide var1 by var2 and assign the result to var1" - }, - "math_modulus": { - "prefix": "math %", - "body": "${1:result}=\\$((${2:var1} % ${3:var2}))\n", - "description": "reminder of dividing var1 by var2 (modulus)" - }, - "math_modulus_equal": { - "prefix": "math %=", - "body": "((${1:var1} %= ${2:var2}))\n", - "description": "divide var1 by var2 and assign the reminder to var1" - }, - "math_power": { - "prefix": "math ^", - "body": "${1:result}=\\$((${2:base} ** ${3:power}))\n", - "description": "exponentiate base to power" - }, - "random_number": { - "prefix": "math random", - "body": "${1:result}=\\$((${2:min} + RANDOM % \\$((${3:max}-${2:min}))))\n", - "description": "generate random integer x such as min <= x <= max" - }, - "math_sqrt": { - "prefix": "math √", - "body": "${1:result}=`echo \"scale=${2|0,1,2,3,4,5,6,7,8,9|};sqrt(${3:\\$var})\" | bc`\n", - "description": "square root of var up to scale decimal places" - }, - "math_float": { - "prefix": "math 0.00", - "body": "${1:result}=`echo \"scale=${2|0,1,2,3,4,5,6,7,8,9|};(${3:\\$var1} ${4|+,-,*,/,^|} ${5:\\$var2})\" | bc`\n", - "description": "math operations with up to scale decimal places precision" - }, - "math_const_pi": { - "prefix": "math const π", - "body": "MATH_PI='3.14159265358979323846264338327950288'\n", - "description": "math PI constant" - }, - "math_const_napier": { - "prefix": "math const e", - "body": "MATH_NAPIER='2.71828182845904523536028747135266249'\n", - "description": "math Napier's constant" - }, - "math_const_gamma": { - "prefix": "math const 𝛾", - "body": "MATH_GAMMA='0.57721566490153286060651209008240243'\n", - "description": "math Euler-Mascheroni constant" - }, - "math_const_phi": { - "prefix": "math const ϕ", - "body": "MATH_GOLDEN_RATIO='1.61803398874989484820458683436563811'\n", - "description": "math golden ration constant" - }, - "math_const_omega": { - "prefix": "math const Ω", - "body": "MATH_OMEGA='0.56714329040978387299996866221035554'\n", - "description": "math Omega constant" - }, - "file_delete": { - "prefix": [ - "file delete", - "file remove" - ], - "body": "rm -f ${1:./path/file}\n", - "description": "delete file(s)" - }, - "file_find": { - "prefix": [ - "file find", - "directory find" - ], - "body": "result=`find ${1:./path} -maxdepth ${2|0,1,2,3,4,5,6,7,8,9|} -type ${3|f,d|} -name \"${4:criteria}\"`\n", - "description": "find files (-type f) or directories (-type d) by name" - }, - "file_read": { - "prefix": "file read", - "body": [ - "cat ${1:\"\\$filepath\"} | while read ${2:line}; do", - "\t${3:echo \"\\$line\"}", - "done\n" - ], - "description": "read a file" - }, - "file_search": { - "prefix": [ - "file search", - "search in files", - "find in files" - ], - "body": "result=`find ${1:./path} -maxdepth ${2|0,1,2,3,4,5,6,7,8,9|} -type f -exec grep \"${3:criteria}\" {} +`\n", - "description": "find files which contain search criteria" - }, - "file_write": { - "prefix": "file write", - "body": [ - "echo \"${1:sample header}\" > ${2:/path/to/file}", - "for ${3:line} in \\${${4:lines}}; do", - "\techo \"\\$${3:line}\" >> ${2:/path/to/file}", - "done\n" - ], - "description": "write a file" - }, - "file_write_multiline": { - "prefix": "file write multiline", - "body": [ - "cat >${1:filepath} <>>>>>>>>>>>>>>>>>>>>>>> ${1:name} >>>>>>>>>>>>>>>>>>>>>>>>", - "$0", - "# <<<<<<<<<<<<<<<<<<<<<<<< ${1:name} <<<<<<<<<<<<<<<<<<<<<<<<" - ], - "description": "Comment out a special region (i.e. variable declarations" - }, - "service_manage": { - "prefix": "service manage", - "body": "sudo systemctl ${1|enable,disable,start,stop,reload,restart,status|} ${2:service}\n", - "description": "Manage service operations" - }, - "stopwatch_start": { - "prefix": "stopwatch start", - "body": "STOPWATCH_START_TIME=\\$(date +%s)\n", - "description": "start stopwatch" - }, - "stopwatch_stop": { - "prefix": "stopwatch stop", - "body": "STOPWATCH_END_TIME=\\$(date +%s)\n", - "description": "stop stopwatch" - }, - "stopwatch_elapsed": { - "prefix": "stopwatch elapsed", - "body": [ - "STOPWATCH_ELAPSED_TOTAL_SECONDS=$((STOPWATCH_END_TIME - STOPWATCH_START_TIME))", - "STOPWATCH_ELAPSED_MINUTES=$((STOPWATCH_ELAPSED_TOTAL_SECONDS / 60))", - "STOPWATCH_ELAPSED_SECONDS=$((STOPWATCH_ELAPSED_TOTAL_SECONDS % 60))", - "${1:echo elapsed \\$STOPWATCH_ELAPSED_MINUTES minutes and \\$STOPWATCH_ELAPSED_SECONDS seconds}\n" - ], - "description": "elapsed time" - }, - "sleep": { - "prefix": "sleep", - "body": "sleep ${1:30}${2|s,m,h,d|}\n", - "description": "sleep for a specified amount of time (s: second, m: minute, h: hour, d: day)" - }, - "system_memory_info": { - "prefix": "system memory info", - "body": "sysMemory${1|MemTotal,MemFree,MemAvailable,Cached,Buffers,Active,Inactive,SwapTotal,SwapFree,SwapCached|}=`cat /proc/meminfo | grep '${1}' | awk '{print \\$2}' | head -n 1`\n", - "description": "System memory information in kilobytes (KB)" - }, - "system_distro_name": { - "prefix": "system distro name", - "body": "lsb_release -i | awk '{print \\$3}'\n", - "description": "OS ID (i.e. Ubuntu)" - }, - "system_distro_version": { - "prefix": "system distro version", - "body": "lsb_release -r | awk '{print \\$2}'\n", - "description": "OS Release (i.e. 16.04)" - }, - "system_distro_codename": { - "prefix": "system distro codename", - "body": "lsb_release -c | awk '{print \\$2}'\n", - "description": "OS codename (i.e. xenial)" - }, - "system_kernel_name": { - "prefix": "system kernel name", - "body": "uname -s\n", - "description": "OS kernel name (i.e. Linux)" - }, - "system_kernel_release": { - "prefix": "system kernel release", - "body": "uname -r\n", - "description": "OS kernel release (i.e. 4.4.0-140-generic)" - }, - "system_processor_type": { - "prefix": "system processor type", - "body": "uname -p\n", - "description": "OS processor type (i.e. x86_64)" - }, - "system_processor_count": { - "prefix": "system processor count", - "body": "lscpu | grep 'CPU(s)' |awk '{print \\$2}' | head -n 1\n", - "description": "Processor count (cores)" - }, - "system_processor_architecture": { - "prefix": "system processor architecture", - "body": "lscpu | grep 'Architecture' |awk '{print \\$2}' | head -n 1\n", - "description": "Processor architecture (i.e. x86_64)" - }, - "system_processor_model": { - "prefix": "system processor model", - "body": "lscpu | grep 'Model name' |cut -d ' ' -f 3- | sed -e 's/^[[:space:]]*//'\n", - "description": "Processor model name (i.e. Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz)" - }, - "system_uptime": { - "prefix": "system uptime", - "body": "sys_uptime=`uptime | cut -d ' ' -f2`\n", - "description": "System uptime (hh:mm:ss)" - }, - "timeout": { - "prefix": "timeout", - "body": "timeout ${1:seconds} ${2:command}\n", - "description": "Run command within a time frame" - }, - "fn_banner_simple": { - "prefix": "fn banner simple", - "body": [ - "# Usage: banner_simple \"my title\"\n", - "function banner_simple() {", - "\tlocal msg=\"* \\$* *\"", - "\tlocal edge=`echo \"\\$msg\" | sed 's/./*/g'`", - "\techo \"\\$edge\"", - "\techo \"`tput bold`\\$msg`tput sgr0`\"", - "\techo \"\\$edge\"", - "\techo", - "}\n" - ], - "description": "function: print a banner with provided title" - }, - "fx_banner_simple": { - "prefix": "fx banner simple", - "body": "banner_simple \"${1:my title}\"\n", - "description": "call banner_simple function" - }, - "fn_banner_color": { - "prefix": "fn banner color", - "body": [ - "# Usage: banner_color green \"my title\"\n", - "function banner_color() {", - "\tlocal color=\\$1", - "\tshift\n", - "\tcase \\$color in", - "\t\tblack) color=0", - "\t\t;;", - "\t\tred) color=1", - "\t\t;;", - "\t\tgreen) color=2", - "\t\t;;", - "\t\tyellow) color=3", - "\t\t;;", - "\t\tblue) color=4", - "\t\t;;", - "\t\tmagenta) color=5", - "\t\t;;", - "\t\tcyan) color=6", - "\t\t;;", - "\t\twhite) color=7", - "\t\t;;", - "\t\t*) echo \"color is not set\"; exit 1", - "\t\t;;", - "\tesac\n", - "\tlocal s=(\"$@\") b w", - "\tfor l in \"\\${s[@]}\"; do", - "\t\t((w<${#l})) && { b=\"\\$l\"; w=\"\\${#l}\"; }", - "\tdone", - "\ttput setaf \\$color", - "\techo \" =\\${b//?/=}=", - "| \\${b//?/ } |\"", - "\tfor l in \"\\${s[@]}\"; do", - "\t\tprintf '| %s%*s%s |\\n' \"\\$(tput setaf \\$color)\" \"-\\$w\" \"\\$l\" \"\\$(tput setaf \\$color)\"", - "\tdone\n", - "\techo \"| ${b//?/ } |", - " =${b//?/=}=\"", - "\ttput sgr 0", - "}\n" - ], - "description": "print a color banner." - }, - "fx_banner_color": { - "prefix": "fx banner color", - "body": "banner_color ${1|black,red,green,yellow,blue,magenta,cyan,white|} \"${2:my title}\"\n", - "description": "call banner_color function" - }, - "fn_import": { - "prefix": "fn import", - "body": [ - "# Usage: import \"mylib\"\n", - "function import() {", - "\tlocal file=\"./${0:lib}/\\$1.sh\"", - "\tif [ -f \"\\$file\" ]; then", - "\t\tsource \"\\$file\"", - "\telse", - "\t\techo \"Error: Cannot find library at: \\$file\"", - "\t\texit 1", - "\tfi", - "}\n" - ], - "description": "import functions from other shellscript files" - }, - "fx_import": { - "prefix": "fx import", - "body": "import \"${1:libname}\"\n", - "description": "call import function, to import functions from other shellscript files located in a directory (default: lib) relative to current script file" - }, - "fn_math_sum": { - "prefix": "fn math sum", - "body": [ - "function sum () {", - "\tlocal result=0", - "\tfor item in \\$@; do", - "\t\t((result += item))", - "\tdone", - "\techo \\$result", - "}\n" - ], - "description": "Calculate sum of given integers" - }, - "fx_math_sum": { - "prefix": "fx math sum", - "body": "result=`sum ${1:\\$var1} ${2:\\$var2} ${3:\\$var3}`\n", - "description": "Call math sum function" - }, - "fn_math_product": { - "prefix": "fn math product", - "body": [ - "function product () {", - "\tlocal result=1", - "\tfor item in $@; do", - "\t\t((result *= item))", - "\tdone", - "\techo \\$result", - "}\n" - ], - "description": "Calculate product of given integers" - }, - "fx_math_product": { - "prefix": "fx math product", - "body": "result=`product ${1:\\$var1} ${2:\\$var2} ${3:\\$var3}`\n", - "description": "Call math product function" - }, - "fn_math_average": { - "prefix": "fn math average", - "body": [ - "function average () {", - "\tlocal result=0", - "\tfor item in \\$@; do", - "\t\t((result += item))", - "\tdone", - "\techo \\$((result / \\$#))", - "}\n" - ], - "description": "Calculate average of given integers" - }, - "fx_math_average": { - "prefix": "fx math average", - "body": "result=`average ${1:\\$var1} ${2:\\$var2} ${3:\\$var3}`\n", - "description": "Call math average function" - }, - "fn_options": { - "prefix": "fn options", - "body": [ - "# Usage: options=(\"one\" \"two\" \"three\"); chooseOption \"Choose:\" 1 \"\\${options[@]}\"; choice=\\$?; echo \"\\${options[\\$choice]}\"\n", - "function chooseOption() {", - "\techo \"\\$1\"; shift", - "\techo `tput sitm``tput dim`-\"Change selection: [up/down] Select: [ENTER]\" `tput sgr0`", - "\tlocal selected=\"\\$1\"; shift\n", - "\tESC=`echo -e \"\\033\"`", - "\tcursor_blink_on() { tput cnorm; }", - "\tcursor_blink_off() { tput civis; }", - "\tcursor_to() { tput cup \\$((\\$1-1)); }", - "\tprint_option() { echo `tput dim` \" \\$1\" `tput sgr0`; }", - "\tprint_selected() { echo `tput bold` \"=> \\$1\" `tput sgr0`; }", - "\tget_cursor_row() { IFS=';' read -sdR -p \\$'\\E[6n' ROW COL; echo \\${ROW#*[}; }", - "\tkey_input() { read -s -n3 key 2>/dev/null >&2; [[ \\$key = \\$ESC[A ]] && echo up; [[ \\$key = \\$ESC[B ]] && echo down; [[ \\$key = \"\" ]] && echo enter; }\n", - "\tfor opt; do echo; done\n", - "\tlocal lastrow=`get_cursor_row`", - "\tlocal startrow=\\$((\\$lastrow - \\$#))", - "\ttrap \"cursor_blink_on; echo; echo; exit\" 2", - "\tcursor_blink_off\n", - "\t: selected:=0\n", - "\twhile true; do", - "\t\tlocal idx=0", - "\t\tfor opt; do", - "\t\t\tcursor_to \\$((\\$startrow + \\$idx))", - "\t\t\tif [ \\$idx -eq \\$selected ]; then", - "\t\t\t\tprint_selected \"\\$opt\"", - "\t\t\telse", - "\t\t\t\tprint_option \"\\$opt\"", - "\t\t\tfi", - "\t\t\t((idx++))", - "\t\tdone\n", - "\t\tcase `key_input` in", - "\t\t\tenter) break;;", - "\t\t\tup) ((selected--)); [ \\$selected -lt 0 ] && selected=\\$((\\$# - 1));;", - "\t\t\tdown) ((selected++)); [ \\$selected -ge \\$# ] && selected=0;;", - "\t\tesac", - "\tdone\n", - "\tcursor_to \\$lastrow", - "\tcursor_blink_on", - "\techo\n", - "\treturn \\$selected", - "}\n" - ], - "description": "provide a list of options to user and return the index of selected option" - }, - "fx_options": { - "prefix": "fx options", - "body": [ - "options=(${1:\"one\" \"two\" \"three\"})", - "chooseOption \"Choose:\" ${2:1} \"\\${options[@]}\"; choice=\\$?", - "echo \"\\${options[\\$choice]}\" selected\n" - ], - "description": "call options function" - }, - "fn_progress": { - "prefix": "fn progress", - "body": [ - "function progressBar() {", - "\tlocal BAR='████████████████████'", - "\tlocal SPACE=' '", - "\tfor i in {1..20}; do", - "\t\techo -ne \"\\r|\\${BAR:0:\\$i}\\${SPACE:\\$i:20}| \\$((\\$i*5))% [ \\$2 ] \"", - "\t\tsleep \\$1", - "\tdone", - "\techo -ne '\n'", - "}\n" - ], - "description": "progress bar function" - }, - "fx_progress": { - "prefix": "fx progress", - "body": "progressBar ${1|.1,.2,.3,.4,.5,1,2,5|} \"${2:Installing foo...}\"\n", - "description": "call progress bar function" - }, - "fn_scan": { - "prefix": "fn scan", - "body": [ - "# Usage: scan proto host fromPort toPort", - "function scan () {", - "\tfor ((port=\\$3; port<=\\$4; port++)); do", - "\t\t(echo >/dev/\\$1/\\$2/\\$port) >/dev/null 2>&1 && echo \"\\$1 \\$port => open\"", - "\tdone", - "}\n" - ], - "description": "Scan host's port range (tcp/udp)" - }, - "fx_scan": { - "prefix": "fx scan", - "body": "scan ${1|tcp,udp|} ${2:host} ${3:fromPort} ${4: toPort}", - "description": "call scan function to scan a host over a port range" - }, - "fn_version_compare": { - "prefix": [ - "fn version compare", - "fn semver compare" - ], - "body": [ - "# Usage: version_compare \"1.2.3\" \"1.1.7\"\n", - "function version_compare () {", - "\tfunction sub_ver () {", - "\t\tlocal len=${#1}", - "\t\ttemp=${1%%\".\"*} && indexOf=`echo ${1%%\".\"*} | echo ${#temp}`", - "\t\techo -e \"\\${1:0:indexOf}\"", - "\t}", - "\tfunction cut_dot () {", - "\t\tlocal offset=${#1}", - "\t\tlocal length=${#2}", - "\t\techo -e \"\\${2:((++offset)):length}\"", - "\t}", - "\tif [ -z \"\\$1\" ] || [ -z \"\\$2\" ]; then", - "\t\techo \"=\" && exit 0", - "\tfi", - "\tlocal v1=`echo -e \"\\${1}\" | tr -d '[[:space:]]'`", - "\tlocal v2=`echo -e \"\\${2}\" | tr -d '[[:space:]]'`", - "\tlocal v1_sub=`sub_ver \\$v1`", - "\tlocal v2_sub=`sub_ver \\$v2`", - "\tif (( v1_sub > v2_sub )); then", - "\t\techo \">\"", - "\telif (( v1_sub < v2_sub )); then", - "\t\techo \"<\"", - "\telse", - "\t\tversion_compare `cut_dot \\$v1_sub \\$v1` `cut_dot \\$v2_sub \\$v2`", - "\tfi", - "}\n" - ], - "description": "function: compares two semvers and returns >, < or =" - }, - "fx_version_compare": { - "prefix": [ - "fx version compare", - "fx semver compare" - ], - "body": "version_compare \"${1:major}.${2:minor}.${3:patch}\" \"${4:major}.${5:minor}.${6:patch}\"\n", - "description": "call version_compare function" - } -} + "archive.compress-tar-gz": { + "prefix": "archive compress tar.gz", + "body": "tar -czvf ${1:/path/to/archive}.tar.gz ${2:/path/to/directory-or-file}\n", + "description": "compress file/folder to a .tar.gz file" + }, + "archive.decompress-tar-gz": { + "prefix": "archive decompress tar.gz", + "body": "tar -C ${1:/extract/to/path} -xzvf ${2:/path/to/archive}.tar.gz\n", + "description": "decompress a .tar.gz file to specified path" + }, + "array.all-elements": { + "prefix": "array all", + "body": "${myArray[@]}\n", + "description": "all array elements" + }, + "array.at-index": { + "prefix": "array at index", + "body": "${myArray[${1:index}]}\n", + "description": "retrieve element at specified index (zero based)" + }, + "array.concat": { + "prefix": "array concat", + "body": "${1:newArray}=(\"${${2:array1}[@]}\" \"${${3:array2}[@]}\")\n", + "description": "concatenate two arrays" + }, + "array.declare": { + "prefix": "array declare", + "body": "${1:myArray}=('${2:one}' '${3:two}' '${4:three}')\n", + "description": "declare an array" + }, + "array.delete-at": { + "prefix": "array delete at", + "body": "unset ${1:myArray}[${2:index}]\n", + "description": "delete element at index from array" + }, + "array.delete": { + "prefix": "array delete", + "body": "unset ${1:myArray}\n", + "description": "delete entire array" + }, + "array.filter": { + "prefix": "array filter", + "body": "${1:filtered}=(`for i in ${${2:myArray}[@]} ; do echo \\$i; done | grep ${3:pattern}`)\n", + "description": "filter elements of an array based on given pattern" + }, + "array.iterate": { + "prefix": [ + "array iterate", + "array forEach" + ], + "body": [ + "for item in ${${1:myArray}[@]}; do", + "\t${2:echo \"\\$item\"}", + "done\n" + ], + "description": "iterate array elements" + }, + "array.length": { + "prefix": "array length", + "body": "${#${1:myArray}[@]}\n", + "description": "length of array" + }, + "array.push": { + "prefix": [ + "array push", + "array add" + ], + "body": "${1:myArray}+=('${2:newItem}')\n", + "description": "push new item to the end of array" + }, + "array.range": { + "prefix": [ + "array slice", + "array range" + ], + "body": "${myArray[@]:${1:from}:${2:count}}\n", + "description": "elements of array from index, equal to count numbers" + }, + "array.replace": { + "prefix": "array replace", + "body": "${myArray[@]//${1:find}/${2:replace}}\n", + "description": "find and replace elements in array using regex" + }, + "array.set-element-at": { + "prefix": "array set element", + "body": "myArray[${1:index}]=${2:value}\n", + "description": "set array element at index" + }, + "command.failure-check": { + "prefix": "cmd failure check", + "body": [ + "if [[ \\$? != 0 ]]; then", + "\t${3:echo command failed}", + "fi\n" + ], + "description": "check if last command failed" + }, + "command.if-exists": { + "prefix": "if cmd exists", + "body": [ + "if [ `command -v ${1:command}` ]; then", + "\t${2:# body}", + "fi\n" + ], + "description": "check if command exists" + }, + "command.nice": { + "prefix": "cmd nice", + "body": "sudo nice -n ${1|-20,-15,-10,-5,0,5,10,15,19|} ${0:command}\n", + "description": "run command with desired privilege. n: -20 (highest priority) to 19 (lowest priority)" + }, + "command.renice": { + "prefix": "cmd renice", + "body": "for p in \\$(pidof \"${process_name}\"); do sudo renice -n ${1|-20,-15,-10,-5,0,5,10,15,19|} -p \\$p; done", + "description": "Change running process priority. n: -20 (highest priority) to 19 (lowest priority)" + }, + "command.run": { + "prefix": "cmd", + "body": "$(${1:command})\n", + "description": "run command (command substitution)" + }, + "command.success-check": { + "prefix": "cmd success check", + "body": [ + "if [[ \\$? == 0 ]]; then", + "\t${3:echo command succeed}", + "fi\n" + ], + "description": "check if last command succeed" + }, + "cryptography.base64-decode": { + "prefix": "crypto base64 decode", + "body": "${1:base64Decoded}=`echo -n \"\\$${2:variableToDecode}\" | base64 -d`\n", + "description": "decode variable from base64" + }, + "cryptography.base64-encode": { + "prefix": "crypto base64 encode", + "body": "${1:base64Encoded}=`echo -n \"\\$${2:variableToEncode}\" | base64`\n", + "description": "encode variable to base64" + }, + "cryptography.hash": { + "prefix": "crypto hash", + "body": "${1:hash}=`echo -n \"\\$${2:variableToHash}\" | ${3|md5sum,shasum,sha1sum,sha224sum,sha256sum,sha384sum,sha512sum|} | cut -f1 -d ' '`\n", + "description": "compute hash of variable (md5, sha, sha1, sha224, sha256, sha384, sha512)" + }, + "date-time.day-of-month-current": { + "prefix": "date now dayOfMonth", + "body": "dayOfMonth=`date +%d`\n", + "description": "current day of month (1..31)" + }, + "date-time.day-of-week-current": { + "prefix": "date now dayOfWeek", + "body": "dayOfWeek=`date +%${1|A,a|}`\n", + "description": "current day of week name (full/abbreviated A/a)" + }, + "date-time.day-of-year-current": { + "prefix": "date now dayOfYear", + "body": "dayOfYear=`date +%j`\n", + "description": "current day of year (1..366)" + }, + "date-time.epoch-seconds": { + "prefix": "time seconds epoch", + "body": "timeNowSecondsEpoch=`date +%s`\n", + "description": "seconds since epoch (1970-01-01 00:00:00)" + }, + "date-time.local-time-current": { + "prefix": "time now local", + "body": "timeNowLocal=`date +%${1|R,r|}`\n", + "description": "current local time (24hrs/12hrs R/r)" + }, + "date-time.month-name-current": { + "prefix": "date now monthName", + "body": "monthName=`date +%${1|B,b|}`\n", + "description": "current month name (full/abbreviated B/b)" + }, + "date-time.month-number-current": { + "prefix": "date now monthNumber", + "body": "monthNumber=`date +%m`\n", + "description": "current month number (1..12)" + }, + "date-time.short": { + "prefix": "date now short", + "body": "dateShort=`date -I`\n", + "description": "yyyy/mm/dd" + }, + "date-time.time-utc": { + "prefix": "time now UTC", + "body": "timeNowUTC=`date -u +%R`\n", + "description": "current UTC time" + }, + "date-time.utc": { + "prefix": "date now UTC", + "body": "dateUTC=`date -u`\n", + "description": "coordinated Universal Time" + }, + "date-time.year-current": { + "prefix": "date now year", + "body": "year=`date +%Y`\n", + "description": "current Year" + }, + "filesystem.directory-create-nested": { + "prefix": "directory create nested", + "body": "mkdir -p \"${1:parent dir}\"/\"${2:child dir}\"\n", + "description": "create nested directories" + }, + "filesystem.directory-create": { + "prefix": "directory create", + "body": "mkdir \"${1:dirname}\"\n", + "description": "create directory" + }, + "filesystem.file-delete": { + "prefix": [ + "file delete", + "file remove" + ], + "body": "rm -f ${1:./path/file}\n", + "description": "delete file(s)" + }, + "filesystem.file-read": { + "prefix": "file read", + "body": [ + "cat ${1:\"\\$filepath\"} | while read ${2:line}; do", + "\t${3:echo \"\\$line\"}", + "done\n" + ], + "description": "read a file" + }, + "filesystem.file-search": { + "prefix": [ + "file search", + "search in files", + "find in files" + ], + "body": "result=`find ${1:./path} -maxdepth ${2|0,1,2,3,4,5,6,7,8,9|} -type f -exec grep \"${3:criteria}\" {} +`\n", + "description": "find files which contain search criteria" + }, + "filesystem.file-write-multiline-sudo": { + "prefix": "file write multiline sudo", + "body": [ + "cat << EOL | sudo tee ${1:filepath}", + "${0:# text here}", + "EOL" + ], + "description": "write multiple lines into file with sudo permission" + }, + "filesystem.file-write-multiline": { + "prefix": "file write multiline", + "body": [ + "cat >${1:filepath} < ${2:/path/to/file}", + "for ${3:line} in \\${${4:lines}}; do", + "\techo \"\\$${3:line}\" >> ${2:/path/to/file}", + "done\n" + ], + "description": "write a file" + }, + "filesystem.find-files-or-directories": { + "prefix": [ + "file find", + "directory find" + ], + "body": "result=`find ${1:./path} -maxdepth ${2|0,1,2,3,4,5,6,7,8,9|} -type ${3|f,d|} -name \"${4:criteria}\"`\n", + "description": "find files (-type f) or directories (-type d) by name" + }, + "filesystem.if-directory-exists": { + "prefix": "if directory exists", + "body": [ + "if [ -d \"\\$${1:directory}\" ]; then", + "\t${0:echo directory exists}", + "fi\n" + ], + "description": "if directory exists" + }, + "filesystem.if-file-executable": { + "prefix": "if file executable", + "body": [ + "if [ -x \"\\$${1:file}\" ]; then", + "\t${0:echo file is executable}", + "fi\n" + ], + "description": "if file executable" + }, + "filesystem.if-file-exists-and-is-symbolic-link": { + "prefix": "if file link", + "body": [ + "if [ -h \"\\$${1:file}\" ]; then", + "\t${0:echo symbolic link}", + "fi\n" + ], + "description": "if file exists and is a symbolic link" + }, + "filesystem.if-file-exists": { + "prefix": "if file exists", + "body": [ + "if [ -f \"\\$${1:file}\" ]; then", + "\t${2:echo file exists}", + "fi\n" + ], + "description": "if file exists" + }, + "filesystem.if-file-not-empty": { + "prefix": "if file not empty", + "body": [ + "if [ -s \"\\$${1:file}\" ]; then", + "\t${2:echo file not empty}", + "fi\n" + ], + "description": "if file size is greater than zero" + }, + "filesystem.if-file-readable": { + "prefix": "if file readable", + "body": [ + "if [ -r \"\\$${1:file}\" ]; then", + "\t${0:echo file is readable}", + "fi\n" + ], + "description": "if file readable" + }, + "filesystem.if-file-writeable": { + "prefix": "if file writeable", + "body": [ + "if [ -w \"\\$${1:file}\" ]; then", + "\t${0:echo file is writeable}", + "fi\n" + ], + "description": "if file writeable" + }, + "filesystem.if-file1-newer-than-file2": { + "prefix": "if file newer", + "body": [ + "if [ \"\\$${1:file1}\" -nt \"\\$${2:file2}\" ]; then", + "\t${0:echo file1 is newer than file2}", + "fi\n" + ], + "description": "if file1 newer than file2" + }, + "filesystem.if-file1-older-than-file2": { + "prefix": "if file older", + "body": [ + "if [ \"\\$${1:file1}\" -ot \"\\$${2:file2}\" ]; then", + "\t${0:echo file1 is older than file2}", + "fi\n" + ], + "description": "if file1 older than file2" + }, + "filesystem.if-files-are-equal": { + "prefix": "if file =", + "body": [ + "if [ \"\\$${1:file1}\" -ef \"\\$${2:file2}\" ]; then", + "\t${0:echo files are equal}", + "fi\n" + ], + "description": "if files are equal" + }, + "filesystem.if-path-exists": { + "prefix": "if exists", + "body": [ + "if [ -e \"\\$${1:path}\" ]; then", + "\t${0:echo exists}", + "fi\n" + ], + "description": "if path exists (file, directory, link...)" + }, + "filesystem.remove-files-older-than": { + "prefix": "remove files older", + "body": "find \"\\$${1:path}\" -mtime +${2:days} | xargs rm -f\n", + "description": "find and remove files older than x days" + }, + "fn-fx.fn-banner-color": { + "prefix": "fn banner color", + "body": [ + "# Usage: banner_color green \"my title\"\n", + "function banner_color() {", + "\tlocal color=\\$1", + "\tshift\n", + "\tcase \\$color in", + "\t\tblack) color=0", + "\t\t;;", + "\t\tred) color=1", + "\t\t;;", + "\t\tgreen) color=2", + "\t\t;;", + "\t\tyellow) color=3", + "\t\t;;", + "\t\tblue) color=4", + "\t\t;;", + "\t\tmagenta) color=5", + "\t\t;;", + "\t\tcyan) color=6", + "\t\t;;", + "\t\twhite) color=7", + "\t\t;;", + "\t\t*) echo \"color is not set\"; exit 1", + "\t\t;;", + "\tesac\n", + "\tlocal s=(\"$@\") b w", + "\tfor l in \"\\${s[@]}\"; do", + "\t\t((w<${#l})) && { b=\"\\$l\"; w=\"\\${#l}\"; }", + "\tdone", + "\ttput setaf \\$color", + "\techo \" =\\${b//?/=}=", + "| \\${b//?/ } |\"", + "\tfor l in \"\\${s[@]}\"; do", + "\t\tprintf '| %s%*s%s |\\n' \"\\$(tput setaf \\$color)\" \"-\\$w\" \"\\$l\" \"\\$(tput setaf \\$color)\"", + "\tdone\n", + "\techo \"| ${b//?/ } |", + " =${b//?/=}=\"", + "\ttput sgr 0", + "}\n" + ], + "description": "print a color banner." + }, + "fn-fx.fn-banner-simple": { + "prefix": "fn banner simple", + "body": [ + "# Usage: banner_simple \"my title\"\n", + "function banner_simple() {", + "\tlocal msg=\"* \\$* *\"", + "\tlocal edge=`echo \"\\$msg\" | sed 's/./*/g'`", + "\techo \"\\$edge\"", + "\techo \"`tput bold`\\$msg`tput sgr0`\"", + "\techo \"\\$edge\"", + "\techo", + "}\n" + ], + "description": "function: print a banner with provided title" + }, + "fn-fx.fn-import": { + "prefix": "fn import", + "body": [ + "# Usage: import \"mylib\"\n", + "function import() {", + "\tlocal file=\"./${0:lib}/\\$1.sh\"", + "\tif [ -f \"\\$file\" ]; then", + "\t\tsource \"\\$file\"", + "\telse", + "\t\techo \"Error: Cannot find library at: \\$file\"", + "\t\texit 1", + "\tfi", + "}\n" + ], + "description": "import functions from other shellscript files" + }, + "fn-fx.fn-math-average": { + "prefix": "fn math average", + "body": [ + "function average () {", + "\tlocal result=0", + "\tfor item in \\$@; do", + "\t\t((result += item))", + "\tdone", + "\techo \\$((result / \\$#))", + "}\n" + ], + "description": "Calculate average of given integers" + }, + "fn-fx.fn-math-product": { + "prefix": "fn math product", + "body": [ + "function product () {", + "\tlocal result=1", + "\tfor item in $@; do", + "\t\t((result *= item))", + "\tdone", + "\techo \\$result", + "}\n" + ], + "description": "Calculate product of given integers" + }, + "fn-fx.fn-math-sum": { + "prefix": "fn math sum", + "body": [ + "function sum () {", + "\tlocal result=0", + "\tfor item in \\$@; do", + "\t\t((result += item))", + "\tdone", + "\techo \\$result", + "}\n" + ], + "description": "Calculate sum of given integers" + }, + "fn-fx.fn-options": { + "prefix": "fn options", + "body": [ + "# Usage: options=(\"one\" \"two\" \"three\"); chooseOption \"Choose:\" 1 \"\\${options[@]}\"; choice=\\$?; echo \"\\${options[\\$choice]}\"\n", + "function chooseOption() {", + "\techo \"\\$1\"; shift", + "\techo `tput sitm``tput dim`-\"Change selection: [up/down] Select: [ENTER]\" `tput sgr0`", + "\tlocal selected=\"\\$1\"; shift\n", + "\tESC=`echo -e \"\\033\"`", + "\tcursor_blink_on() { tput cnorm; }", + "\tcursor_blink_off() { tput civis; }", + "\tcursor_to() { tput cup \\$((\\$1-1)); }", + "\tprint_option() { echo `tput dim` \" \\$1\" `tput sgr0`; }", + "\tprint_selected() { echo `tput bold` \"=> \\$1\" `tput sgr0`; }", + "\tget_cursor_row() { IFS=';' read -sdR -p \\$'\\E[6n' ROW COL; echo \\${ROW#*[}; }", + "\tkey_input() { read -s -n3 key 2>/dev/null >&2; [[ \\$key = \\$ESC[A ]] && echo up; [[ \\$key = \\$ESC[B ]] && echo down; [[ \\$key = \"\" ]] && echo enter; }\n", + "\tfor opt; do echo; done\n", + "\tlocal lastrow=`get_cursor_row`", + "\tlocal startrow=\\$((\\$lastrow - \\$#))", + "\ttrap \"cursor_blink_on; echo; echo; exit\" 2", + "\tcursor_blink_off\n", + "\t: selected:=0\n", + "\twhile true; do", + "\t\tlocal idx=0", + "\t\tfor opt; do", + "\t\t\tcursor_to \\$((\\$startrow + \\$idx))", + "\t\t\tif [ \\$idx -eq \\$selected ]; then", + "\t\t\t\tprint_selected \"\\$opt\"", + "\t\t\telse", + "\t\t\t\tprint_option \"\\$opt\"", + "\t\t\tfi", + "\t\t\t((idx++))", + "\t\tdone\n", + "\t\tcase `key_input` in", + "\t\t\tenter) break;;", + "\t\t\tup) ((selected--)); [ \\$selected -lt 0 ] && selected=\\$((\\$# - 1));;", + "\t\t\tdown) ((selected++)); [ \\$selected -ge \\$# ] && selected=0;;", + "\t\tesac", + "\tdone\n", + "\tcursor_to \\$lastrow", + "\tcursor_blink_on", + "\techo\n", + "\treturn \\$selected", + "}\n" + ], + "description": "provide a list of options to user and return the index of selected option" + }, + "fn-fx.fn-progress": { + "prefix": "fn progress", + "body": [ + "function progressBar() {", + "\tlocal BAR='████████████████████'", + "\tlocal SPACE=' '", + "\tfor i in {1..20}; do", + "\t\techo -ne \"\\r|\\${BAR:0:\\$i}\\${SPACE:\\$i:20}| \\$((\\$i*5))% [ \\$2 ] \"", + "\t\tsleep \\$1", + "\tdone", + "\techo -ne '\n'", + "}\n" + ], + "description": "progress bar function" + }, + "fn-fx.fn-scan": { + "prefix": "fn scan", + "body": [ + "# Usage: scan proto host fromPort toPort", + "function scan () {", + "\tfor ((port=\\$3; port<=\\$4; port++)); do", + "\t\t(echo >/dev/\\$1/\\$2/\\$port) >/dev/null 2>&1 && echo \"\\$1 \\$port => open\"", + "\tdone", + "}\n" + ], + "description": "Scan host's port range (tcp/udp)" + }, + "fn-fx.fn-version-compare": { + "prefix": [ + "fn version compare", + "fn semver compare" + ], + "body": [ + "# Usage: version_compare \"1.2.3\" \"1.1.7\"\n", + "function version_compare () {", + "\tfunction sub_ver () {", + "\t\tlocal len=${#1}", + "\t\ttemp=${1%%\".\"*} && indexOf=`echo ${1%%\".\"*} | echo ${#temp}`", + "\t\techo -e \"\\${1:0:indexOf}\"", + "\t}", + "\tfunction cut_dot () {", + "\t\tlocal offset=${#1}", + "\t\tlocal length=${#2}", + "\t\techo -e \"\\${2:((++offset)):length}\"", + "\t}", + "\tif [ -z \"\\$1\" ] || [ -z \"\\$2\" ]; then", + "\t\techo \"=\" && exit 0", + "\tfi", + "\tlocal v1=`echo -e \"\\${1}\" | tr -d '[[:space:]]'`", + "\tlocal v2=`echo -e \"\\${2}\" | tr -d '[[:space:]]'`", + "\tlocal v1_sub=`sub_ver \\$v1`", + "\tlocal v2_sub=`sub_ver \\$v2`", + "\tif (( v1_sub > v2_sub )); then", + "\t\techo \">\"", + "\telif (( v1_sub < v2_sub )); then", + "\t\techo \"<\"", + "\telse", + "\t\tversion_compare `cut_dot \\$v1_sub \\$v1` `cut_dot \\$v2_sub \\$v2`", + "\tfi", + "}\n" + ], + "description": "function: compares two semvers and returns >, < or =" + }, + "fn-fx.fx-banner-color": { + "prefix": "fx banner color", + "body": "banner_color ${1|black,red,green,yellow,blue,magenta,cyan,white|} \"${2:my title}\"\n", + "description": "call banner_color function" + }, + "fn-fx.fx-banner-simple": { + "prefix": "fx banner simple", + "body": "banner_simple \"${1:my title}\"\n", + "description": "call banner_simple function" + }, + "fn-fx.fx-import": { + "prefix": "fx import", + "body": "import \"${1:libname}\"\n", + "description": "call import function, to import functions from other shellscript files located in a directory (default: lib) relative to current script file" + }, + "fn-fx.fx-math-average": { + "prefix": "fx math average", + "body": "result=`average ${1:\\$var1} ${2:\\$var2} ${3:\\$var3}`\n", + "description": "Call math average function" + }, + "fn-fx.fx-math-product": { + "prefix": "fx math product", + "body": "result=`product ${1:\\$var1} ${2:\\$var2} ${3:\\$var3}`\n", + "description": "Call math product function" + }, + "fn-fx.fx-math-sum": { + "prefix": "fx math sum", + "body": "result=`sum ${1:\\$var1} ${2:\\$var2} ${3:\\$var3}`\n", + "description": "Call math sum function" + }, + "fn-fx.fx-options": { + "prefix": "fx options", + "body": [ + "options=(${1:\"one\" \"two\" \"three\"})", + "chooseOption \"Choose:\" ${2:1} \"\\${options[@]}\"; choice=\\$?", + "echo \"\\${options[\\$choice]}\" selected\n" + ], + "description": "call options function" + }, + "fn-fx.fx-progress": { + "prefix": "fx progress", + "body": "progressBar ${1|.1,.2,.3,.4,.5,1,2,5|} \"${2:Installing foo...}\"\n", + "description": "call progress bar function" + }, + "fn-fx.fx-scan": { + "prefix": "fx scan", + "body": "scan ${1|tcp,udp|} ${2:host} ${3:fromPort} ${4: toPort}", + "description": "call scan function to scan a host over a port range" + }, + "fn-fx.fx-version-compare": { + "prefix": [ + "fx version compare", + "fx semver compare" + ], + "body": "version_compare \"${1:major}.${2:minor}.${3:patch}\" \"${4:major}.${5:minor}.${6:patch}\"\n", + "description": "call version_compare function" + }, + "ftp.delete": { + "prefix": "ftp delete file", + "body": "curl ftp://${1:user}:${2:password}@${3:ipOrDomain}/${4:path}/${5:fileToDelete} -Q \"DELE ${5:fileToDelete}\"\n", + "description": "Delete specified file from ftp server" + }, + "ftp.download": { + "prefix": "ftp download", + "body": "curl ftp://${1:user}:${2:password}@${3:ipOrDomain}/${4:filePathOnServer}/\n", + "description": "Download specified file from ftp server" + }, + "ftp.list-of-files": { + "prefix": "ftp list", + "body": "curl ftp://${1:user}:${2:password}@${3:ipOrDomain}/${4:directoryPathOnServer}/\n", + "description": "Get the list of files on the ftp server at specific path" + }, + "ftp.rename": { + "prefix": "ftp rename", + "body": "curl ftp://${1:user}:${2:password}@${3:ipOrDomain}/${4:path}/ -Q \"-RNFR ${4:path}/${5:renameFrom}\" -Q \"-RNTO ${4:path}/${6:renameTo}\"\n", + "description": "Rename specified file/directory on ftp server" + }, + "ftp.upload": { + "prefix": "ftp upload", + "body": "curl -T ${1:fileToUpload} ftp://${2:user}:${3:password}@${4:ipOrDomain}/${5:directoryPathOnServer}/\n", + "description": "Upload specified file to ftp server" + }, + "function.arguments-array": { + "prefix": "func args", + "body": "echo \"$@\"", + "description": "function arguments array" + }, + "function.arguments-count": { + "prefix": "func args count", + "body": "echo $#", + "description": "number of function arguments" + }, + "function.declare": { + "prefix": "func", + "body": [ + "function ${1:name} () {", + "\t${2:echo \"\\$1\" # arguments are accessible through $1, $2,...}", + "}\n" + ], + "description": "function" + }, + "function.return-value": { + "prefix": "func ret val", + "body": "echo \"$?\"", + "description": "last function/command return code" + }, + "git.branch-create": { + "prefix": "git branch create", + "body": "git checkout -b ${1:branchName}\n", + "description": "Create branch locally and switch into it." + }, + "git.branch-delete-local": { + "prefix": "git branch delete local", + "body": "git branch --delete ${1:localBranch}\n", + "description": "Delete local branch." + }, + "git.branch-delete-remote": { + "prefix": "git branch delete remote", + "body": "git push origin --delete ${1:remoteBranch}\n", + "description": "Delete remote branch." + }, + "git.branch-list": { + "prefix": "git branch list", + "body": "git branch\n", + "description": "List all branches." + }, + "git.branch-push": { + "prefix": "git branch push", + "body": "git push origin ${1:branchName}\n", + "description": "Push branch to remote." + }, + "git.branch-rename": { + "prefix": "git branch rename", + "body": "git branch -m ${1:newName}\n", + "description": "Rename current branch." + }, + "git.changes-revert": { + "prefix": "git changes revert", + "body": "git checkout .\n", + "description": "Revert tracked changes" + }, + "git.clone-branch": { + "prefix": "git clone branch", + "body": "git clone -b ${1:branchName} https://${2:github.com}/${3:user}/${4:repository}.git\n", + "description": "Clone a remote branch to local machine." + }, + "git.clone": { + "prefix": "git clone", + "body": "git clone https://${1:github.com}/${2:user}/${3:repository}.git\n", + "description": "Clone remote repository to local machine." + }, + "git.commit-list": { + "prefix": "git commit list notPushed", + "body": "git log origin/master..HEAD\n", + "description": "List non pushed commits." + }, + "git.commit-search": { + "prefix": "git commit search", + "body": "git log --all --grep='${1:searchCriteria}'\n", + "description": "Search for a commit which contains searchCriteria." + }, + "git.commit-undo": { + "prefix": "git commit undo", + "body": "git reset --${1|soft,hard|} HEAD~${2|1,2,3,4,5|}\n", + "description": "Undo last N commits (soft: preserve local changes | hard: delete local changes" + }, + "git.commit": { + "prefix": "git commit", + "body": "git commit -m \"${1:commit message}\"\n", + "description": "Commit changes." + }, + "git.config-list": { + "prefix": "git config list", + "body": "git config --list\n", + "description": "List git configurations." + }, + "git.config-set": { + "prefix": "git config set", + "body": "git config --${1|local,global|} ${2|user.name,user.email|} \"${3:value}\"\n", + "description": "Configure git." + }, + "git.patch-apply": { + "prefix": "git patch apply", + "body": "git apply < ${0:/path/to/patch1.patch}\n", + "description": "Apply a patch from file." + }, + "git.patch-create": { + "prefix": "git patch create", + "body": "git diff > ${0:/path/to/patch1.patch}\n", + "description": "Create a patch from changes." + }, + "git.remote-list": { + "prefix": "git remote list", + "body": "git remote\n", + "description": "List all remotes." + }, + "git.remote-url-change": { + "prefix": "git remote urlChange", + "body": "git remote set-url origin https://${1:github.com}/${2:user}/${3:repository}.git\n", + "description": "Change remote url." + }, + "git.remote-urlAdd": { + "prefix": "git remote urlAdd", + "body": "git remote add origin https://${1:github.com}/${2:user}/${3:repository}.git\n", + "description": "Add remote url." + }, + "git.tag-commit": { + "prefix": [ + "git tag commit", + "git commit tag" + ], + "body": "git tag -a ${1:release/1.0.0} -m \"${2:1.0.0 release}\"\n", + "description": "Tag a commit." + }, + "git.tag-list": { + "prefix": "git tag list", + "body": "git tag\n", + "description": "List all tags." + }, + "git.tag-remote-delete": { + "prefix": "git tag remote delete", + "body": "git push --delete origin ${1:tagName} && git push origin :${1:tagName}\n", + "description": "Delete tag from remote." + }, + "git.tag-remote-push": { + "prefix": "git tag remote push", + "body": "git push origin ${1:tagName}\n", + "description": "Push tag to remote." + }, + "http.cookie": { + "prefix": "http cookie", + "body": [ + "curl --request ${1|GET,POST,DELETE,PUT|} -sL \\", + "\t--user-agent '${2|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \\", + "\t--cookie '${3:key}=${4:value}' \\", + "\t--url '${5:http://example.com}'\n" + ], + "description": "Send http request with cookies, using curl" + }, + "http.download": { + "prefix": "http download", + "body": [ + "curl --request ${1|GET,POST|} -sL \\", + "\t--user-agent '${2|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \\", + "\t--output '${3:/path/to/file}' \\", + "\t--url '${4:http://example.com/file.zip}'\n" + ], + "description": "Download from url and save to /path/to/file, using curl" + }, + "http.get": { + "prefix": [ + "http GET", + "http DELETE" + ], + "body": [ + "curl --request ${1|GET,DELETE|} -sL \\", + "\t--user-agent '${2|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \\", + "\t--url '${3:http://example.com}'\n" + ], + "description": "Send http GET/DELETE request using curl" + }, + "http.header": { + "prefix": "http header", + "body": [ + "curl --request ${1|GET,POST,DELETE,PUT|} -sL \\", + "\t--user-agent '${2|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \\", + "\t--header '${3:key}: ${4:value}' \\", + "\t--url '${5:http://example.com}'\n" + ], + "description": "Send http request with custom header, using curl" + }, + "http.post-send-file": { + "prefix": "http POST file", + "body": [ + "curl --request POST -sL \\", + "\t--user-agent '${1|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \\", + "\t--url '${2:http://example.com}' \\", + "\t--form '${3:key}=${4:value}' \\", + "\t--form 'file=@${5:/path/to/file}'\n" + ], + "description": "Send file with http POST, using curl" + }, + "http.post": { + "prefix": [ + "http POST", + "http PUT" + ], + "body": [ + "curl --request ${1|POST,PUT|} -sL \\", + "\t--user-agent '${2|Shellman,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/58.0.3029.110 Safari/537.36,Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML\\, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393|}' \\", + "\t--url '${3:http://example.com}' \\", + "\t--data '${4:key}=${5:value}' \\", + "\t--data '${6:key}=${7:value}'\n" + ], + "description": "Send data with http POST/PUT, using curl" + }, + "input.ask-question": { + "prefix": "ask question", + "body": [ + "read -ep \"${1:Question here? }\" -i ${2:Default answer} ANSWER", + "${3:echo \"\\$ANSWER\"}\n" + ], + "description": "Ask question with default answer" + }, + "integer.if-equal": { + "prefix": "if int =", + "body": [ + "if (( ${1:int1} == ${2:int2} )); then", + "\t${3:echo equal}", + "fi\n" + ], + "description": "if integers are equal" + }, + "integer.if-greater-or-equal": { + "prefix": "if int >=", + "body": [ + "if (( ${1:int} >= ${2:val} )); then", + "\t${3:echo greater equal}", + "fi\n" + ], + "description": "if integer greater than or equal value" + }, + "integer.if-greater": { + "prefix": "if int >", + "body": [ + "if (( ${1:int} > ${2:val} )); then", + "\t${3:echo greater}", + "fi\n" + ], + "description": "if integer greater than value" + }, + "integer.if-lesser-or-equal": { + "prefix": "if int <=", + "body": [ + "if (( ${1:int} <= ${2:val} )); then", + "\t${3:echo lesser equal}", + "fi\n" + ], + "description": "if integer lesser than or equal value" + }, + "integer.if-lesser": { + "prefix": "if int <", + "body": [ + "if (( ${1:int} < ${2:val} )); then", + "\t${3:echo lesser}", + "fi\n" + ], + "description": "if integer lesser than value" + }, + "integer.if-not-equal": { + "prefix": "if int !=", + "body": [ + "if (( ${1:int1} != ${2:int2} )); then", + "\t${3:echo not equal}", + "fi\n" + ], + "description": "if integers are not equal" + }, + "ip.array-of-local": { + "prefix": "ips", + "body": "IPS=`hostname -I`\n", + "description": "Array of local IPs" + }, + "ip.info": { + "prefix": "ip info", + "body": "echo `curl -s ipinfo.io/${1|ip,city,region,country,loc,postal,org|}`\n", + "description": "public ip information" + }, + "ip.public-address": { + "prefix": "ip public", + "body": "PUBLIC_IP=`curl -s ${1|bot.whatismyipaddress.com,ident.me,ipecho.net/plain,icanhazip.com,ifconfig.me,api.ipify.org,ipinfo.io/ip|}`\n", + "description": "public ip address" + }, + "lang.for-i-j": { + "prefix": "for ij", + "body": [ + "for((i=0;i<${1:n};i++)); do", + "\tfor((j=0;j<${2:m};j++)); do", + "\t\t${0:echo \"\\$i, \\$j\"}", + "\tdone", + "done\n" + ], + "description": "for loop by index" + }, + "lang.for-i": { + "prefix": "for i", + "body": [ + "for((i=0;i<${1:n};i++)); do", + "\t${0:echo \"\\$i\"}", + "done\n" + ], + "description": "for loop by index" + }, + "lang.for-in-collection": { + "prefix": "for in", + "body": [ + "for ${1:item} in {${2:a..z}}; do", + "\techo \"\\$${1:item}\"", + "done\n" + ], + "description": "for loop in collection" + }, + "lang.for-in-column": { + "prefix": "for in column", + "body": [ + "for ${1:col} in `${2:docker images} | awk '{ print ${3:\\$1\":\"\\$2} }'`; do", + "\t${4:echo \"\\$col\" | cut -d ':' -f 1}", + "\t${5:echo \"\\$col\" | cut -d ':' -f 2}", + "done\n" + ], + "description": "for loop in collection" + }, + "lang.if-elif-else": { + "prefix": "if", + "body": [ + "if [ ${1:condition} ]; then", + "\t${2: # body}", + "elif [ ${3:condition} ]; then", + "\t${4: # body}", + "else", + "\t${5: # body}", + "fi\n" + ], + "description": "if" + }, + "lang.if-not": { + "prefix": "iff not", + "body": "[ ${1:condition} ] || ${2:command}\n", + "description": "if condition is false then run command (short circuit)" + }, + "lang.if": { + "prefix": "iff", + "body": "[ ${1:condition} ] && ${2:command}\n", + "description": "if condition is true then run command (short circuit)" + }, + "lang.switch": { + "prefix": "switch case", + "body": [ + "case \"\\$${1:item}\" in", + "\t${2:1})", + "\t\t${3:echo \"case 1\"}", + "\t;;", + "\t${4:2|3})", + "\t\t${5:echo \"case 2 or 3\"}", + "\t;;", + "\t*)", + "\t\t${6:echo \"default\"}", + "\t;;", + "esac\n" + ], + "description": "switch case" + }, + "lang.until": { + "prefix": "until", + "body": [ + "until [ ${1:condition} ]; do", + "\t${0:# body}", + "done\n" + ], + "description": "until loop" + }, + "lang.while": { + "prefix": "while", + "body": [ + "while [ ${1:condition} ]; do", + "\t${0:# body}", + "done\n" + ], + "description": "while loop" + }, + "math.add": { + "prefix": "math +", + "body": "${1:result}=\\$((${2:var1} + ${3:var2}))\n", + "description": "add two variables" + }, + "math.const-gamma": { + "prefix": "math const 𝛾", + "body": "MATH_GAMMA='0.57721566490153286060651209008240243'\n", + "description": "math Euler-Mascheroni constant" + }, + "math.const-napier": { + "prefix": "math const e", + "body": "MATH_NAPIER='2.71828182845904523536028747135266249'\n", + "description": "math Napier's constant" + }, + "math.const-omega": { + "prefix": "math const Ω", + "body": "MATH_OMEGA='0.56714329040978387299996866221035554'\n", + "description": "math Omega constant" + }, + "math.const-phi": { + "prefix": "math const ϕ", + "body": "MATH_GOLDEN_RATIO='1.61803398874989484820458683436563811'\n", + "description": "math golden ration constant" + }, + "math.const-pi": { + "prefix": "math const π", + "body": "MATH_PI='3.14159265358979323846264338327950288'\n", + "description": "math PI constant" + }, + "math.decrement": { + "prefix": "math --", + "body": "((${1|var--,--var|}))\n", + "description": "decrement variable" + }, + "math.divide-equal": { + "prefix": "math /=", + "body": "((${1:var1} /= ${2:var2}))\n", + "description": "divide var1 by var2 and assign the result to var1" + }, + "math.divide": { + "prefix": "math /", + "body": "${1:result}=\\$((${2:var1} / ${3:var2}))\n", + "description": "divide var1 by var2" + }, + "math.float": { + "prefix": "math 0.00", + "body": "${1:result}=`echo \"scale=${2|0,1,2,3,4,5,6,7,8,9|};(${3:\\$var1} ${4|+,-,*,/,^|} ${5:\\$var2})\" | bc`\n", + "description": "math operations with up to scale decimal places precision" + }, + "math.increment": { + "prefix": "math ++", + "body": "((${1|var++,++var|}))\n", + "description": "increment variable" + }, + "math.minus-equal": { + "prefix": "math -=", + "body": "((${1:var1} -= ${2:var2}))\n", + "description": "subtract var2 from var1 and assign the result to var1" + }, + "math.modulus-equal": { + "prefix": "math %=", + "body": "((${1:var1} %= ${2:var2}))\n", + "description": "divide var1 by var2 and assign the reminder to var1" + }, + "math.modulus": { + "prefix": "math %", + "body": "${1:result}=\\$((${2:var1} % ${3:var2}))\n", + "description": "reminder of dividing var1 by var2 (modulus)" + }, + "math.multiply-equal": { + "prefix": "math *=", + "body": "((${1:var1} *= ${2:var2}))\n", + "description": "multiply var1 by var2 and assign the result to var1" + }, + "math.multiply": { + "prefix": "math *", + "body": "${1:result}=\\$((${2:var1} * ${3:var2}))\n", + "description": "multiply var1 by var2" + }, + "math.plus-equal": { + "prefix": "math +=", + "body": "((${1:var1} += ${2:var2}))\n", + "description": "add var1 and var2 and assign the result to var1" + }, + "math.power": { + "prefix": "math ^", + "body": "${1:result}=\\$((${2:base} ** ${3:power}))\n", + "description": "exponentiate base to power" + }, + "math.random-number": { + "prefix": "math random", + "body": "${1:result}=\\$((${2:min} + RANDOM % \\$((${3:max}-${2:min}))))\n", + "description": "generate random integer x such as min <= x <= max" + }, + "math.sqrt": { + "prefix": "math √", + "body": "${1:result}=`echo \"scale=${2|0,1,2,3,4,5,6,7,8,9|};sqrt(${3:\\$var})\" | bc`\n", + "description": "square root of var up to scale decimal places" + }, + "math.subtract": { + "prefix": "math -", + "body": "${1:result}=\\$((${2:var1} - ${3:var2}))\n", + "description": "subtract var2 from var1" + }, + "misc.arguments-parse": { + "prefix": [ + "argument parsing", + "parse args" + ], + "body": [ + "POSITIONAL=()", + "while [[ \\$# > 0 ]]; do", + "\tcase \"\\$1\" in", + "\t\t-f|--flag)", + "\t\techo flag: \\$1", + "\t\tshift # shift once since flags have no values", + "\t\t;;", + "\t\t-s|--switch)", + "\t\techo switch \\$1 with value: \\$2", + "\t\tshift 2 # shift twice to bypass switch and its value", + "\t\t;;", + "\t\t*) # unknown flag/switch", + "\t\tPOSITIONAL+=(\"\\$1\")", + "\t\tshift", + "\t\t;;", + "\tesac", + "done\n", + "set -- \"\\${POSITIONAL[@]}\" # restore positional params\n" + ], + "description": "parse command line arguments (flags/switches)" + }, + "misc.expr": { + "prefix": "expr", + "body": "expr ${1:2} ${2|+,-,\\*,/,%|} ${3:3}\n", + "description": "arithmetic operations" + }, + "misc.let": { + "prefix": "let", + "body": "let \"${1:result} = ${2:var1} ${3|+,-,*,/,%|} ${4:var2}\"\n", + "description": "arithmetic operations" + }, + "misc.region": { + "prefix": "region", + "body": [ + "# >>>>>>>>>>>>>>>>>>>>>>>> ${1:name} >>>>>>>>>>>>>>>>>>>>>>>>", + "$0", + "# <<<<<<<<<<<<<<<<<<<<<<<< ${1:name} <<<<<<<<<<<<<<<<<<<<<<<<" + ], + "description": "Comment out a special region (i.e. variable declarations" + }, + "misc.shebang": { + "prefix": [ + "bash", + "shebang" + ], + "body": "#!/usr/bin/env ${1|bash,node,perl,php,python,python3,ruby|}\n\n", + "description": "bash shebang" + }, + "misc.sleep": { + "prefix": "sleep", + "body": "sleep ${1:30}${2|s,m,h,d|}\n", + "description": "sleep for a specified amount of time (s: second, m: minute, h: hour, d: day)" + }, + "misc.stopwatch-elapsed": { + "prefix": "stopwatch elapsed", + "body": [ + "STOPWATCH_ELAPSED_TOTAL_SECONDS=$((STOPWATCH_END_TIME - STOPWATCH_START_TIME))", + "STOPWATCH_ELAPSED_MINUTES=$((STOPWATCH_ELAPSED_TOTAL_SECONDS / 60))", + "STOPWATCH_ELAPSED_SECONDS=$((STOPWATCH_ELAPSED_TOTAL_SECONDS % 60))", + "${1:echo elapsed \\$STOPWATCH_ELAPSED_MINUTES minutes and \\$STOPWATCH_ELAPSED_SECONDS seconds}\n" + ], + "description": "elapsed time" + }, + "misc.stopwatch-start": { + "prefix": "stopwatch start", + "body": "STOPWATCH_START_TIME=\\$(date +%s)\n", + "description": "start stopwatch" + }, + "misc.stopwatch-stop": { + "prefix": "stopwatch stop", + "body": "STOPWATCH_END_TIME=\\$(date +%s)\n", + "description": "stop stopwatch" + }, + "misc.summary": { + "prefix": "summary", + "body": [ + "# Title: ${1:title}", + "# Description: ${2:description}", + "# Author: ${3:author }", + "# Date: ${4:yyyy-mm-dd}", + "# Version: ${5:1.0.0}\n" + ], + "description": "script summary" + }, + "misc.timeout": { + "prefix": "timeout", + "body": "timeout ${1:seconds} ${2:command}\n", + "description": "Run command within a time frame" + }, + "misc.variable-default-value": { + "prefix": "assign if empty", + "body": ": \"\\${${1:variable}:=${2:default}}\"", + "description": "assign default to variable if variable is empty or null" + }, + "output.color-black": { + "prefix": "color black", + "body": "echo `tput setaf 0`${0:black text}`tput sgr0`\n", + "description": "write in black" + }, + "output.color-blue": { + "prefix": "color blue", + "body": "echo `tput setaf 4`${0:blue text}`tput sgr0`\n", + "description": "write in blue" + }, + "output.color-cyan": { + "prefix": "color cyan", + "body": "echo `tput setaf 6`${0:cyan text}`tput sgr0`\n", + "description": "write in cyan" + }, + "output.color-green": { + "prefix": "color green", + "body": "echo `tput setaf 2`${0:green text}`tput sgr0`\n", + "description": "write in green" + }, + "output.color-magenta": { + "prefix": "color magenta", + "body": "echo `tput setaf 5`${0:magenta text}`tput sgr0`\n", + "description": "write in magenta" + }, + "output.color-red": { + "prefix": "color red", + "body": "echo `tput setaf 1`${0:red text}`tput sgr0`\n", + "description": "write in red" + }, + "output.color-white": { + "prefix": "color white", + "body": "echo `tput setaf 7`${0:white text}`tput sgr0`\n", + "description": "write in white" + }, + "output.color-yellow": { + "prefix": "color yellow", + "body": "echo `tput setaf 3`${0:yellow text}`tput sgr0`\n", + "description": "write in yellow" + }, + "output.format-bold": { + "prefix": "format bold", + "body": "echo `tput bold`${0:bold text}`tput sgr0`\n", + "description": "write in bold" + }, + "output.format-dim": { + "prefix": "format dim", + "body": "echo `tput dim`${0:dimmed text}`tput sgr0`\n", + "description": "write in dim" + }, + "output.format-italic": { + "prefix": "format italic", + "body": "echo `tput sitm`${0:italic text}`tput sgr0`\n", + "description": "write in italic" + }, + "output.format-reverse": { + "prefix": "format reverse", + "body": "echo `tput rev`${0:reversed text}`tput sgr0`\n", + "description": "write in reverse" + }, + "string.contains": { + "prefix": [ + "string contains", + "if string contains" + ], + "body": [ + "if [[ \"\\$${1:string}\" = *${2:substring}* ]]; then", + "\t${3:# body}", + "fi\n" + ], + "description": "check whether string contains substring" + }, + "string.first-index-substring": { + "prefix": "string indexOf", + "body": [ + "temp=\\${${1:string}%%\"${2:substring}\"*} && indexOf=`echo \\${${1:string}%%\"${2:substring}\"*} | echo \\${#temp}`", + "${0:# echo \\$indexOf}" + ], + "description": "first index of substring in string" + }, + "string.if-empty": { + "prefix": "if string empty", + "body": [ + "if [ -z \"\\$${1:string}\" ]; then", + "\t${2:# body}", + "fi\n" + ], + "description": "if string is empty" + }, + "string.if-equal": { + "prefix": [ + "if string =", + "string equal" + ], + "body": [ + "if [ \"\\$${1:string1}\" = \"\\$${2:string2}\" ]; then", + "\t${3:# body}", + "fi\n" + ], + "description": "if strings are equal" + }, + "string.if-not-empty": { + "prefix": "if string not empty", + "body": [ + "if [ -n \"\\$${1:string}\" ]; then", + "\t${2:# body}", + "fi\n" + ], + "description": "if string is not empty" + }, + "string.if-not-equal": { + "prefix": [ + "if string !=", + "string not equal" + ], + "body": [ + "if [ \"\\$${1:string1}\" != \"\\$${2:string2}\" ]; then", + "\t${3:# body}", + "fi\n" + ], + "description": "if strings are not equal" + }, + "string.length": { + "prefix": "string length", + "body": "length=\\${#${1:variable}}\n", + "description": "length of string in characters" + }, + "string.replace": { + "prefix": "string replace", + "body": "${1:replaced}=`echo -e \"\\${${2:var}}\" | sed -e 's/${3:find}/${4:replace}/g'`", + "description": "find all occurrences of a substrings and replace them" + }, + "string.reverse": { + "prefix": "string reverse", + "body": "reversed=`echo -e \"\\${${1:var}}\" | rev`", + "description": "reverse string characters" + }, + "string.substring-count": { + "prefix": [ + "string substring count", + "string substring frequency" + ], + "body": "frequency=`sed -E 's/(.)/\\1\\n/g' <<<\"${1:string}\" | grep -c \"${2:substring}\"`\n", + "description": "Frequency of a substring in a string (may need character escaping)" + }, + "string.substring": { + "prefix": "string substring", + "body": "substring=`echo -e \"\\${${1:var}:${2:offset}:${3:length}}\"`\n", + "description": "part of the string from offset with length characters" + }, + "string.to-lower": { + "prefix": "string toLower", + "body": "toLower=`echo -e \"\\${${1:var}}\" | tr '[:upper:]' '[:lower:]'`", + "description": "convert string to lowercase" + }, + "string.to-upper": { + "prefix": "string toUpper", + "body": "toUpper=`echo -e \"\\${${1:var}}\" | tr '[:lower:]' '[:upper:]'`", + "description": "convert string to uppercase" + }, + "string.trim-all": { + "prefix": "string trim all", + "body": "${1:trimmed}=`echo -e \"\\${${2:var}}\" | tr -d '[[:space:]]'`", + "description": "remove all white space(s)" + }, + "string.trim-left": { + "prefix": "string trim left", + "body": "${1:trimmed}=`echo -e \"\\${${2:var}}\" | sed -e 's/^[[:space:]]*//'`", + "description": "remove leading white space(s)" + }, + "string.trim-right": { + "prefix": "string trim right", + "body": "${1:trimmed}=`echo -e \"\\${${2:var}}\" | sed -e 's/[[:space:]]*$//'`", + "description": "remove trailing white space(s)" + }, + "string.trim": { + "prefix": "string trim", + "body": "${1:trimmed}=`echo -e \"\\${${2:var}}\" | sed -e 's/^[[:space:]]*//' | sed -e 's/[[:space:]]*\\$//'`", + "description": "remove leading and trailing white space(s)" + }, + "system.distro-codename": { + "prefix": "system distro codename", + "body": "lsb_release -c | awk '{print \\$2}'\n", + "description": "OS codename (i.e. xenial)" + }, + "system.distro-name": { + "prefix": "system distro name", + "body": "lsb_release -i | awk '{print \\$3}'\n", + "description": "OS ID (i.e. Ubuntu)" + }, + "system.distro-version": { + "prefix": "system distro version", + "body": "lsb_release -r | awk '{print \\$2}'\n", + "description": "OS Release (i.e. 16.04)" + }, + "system.kernel-name": { + "prefix": "system kernel name", + "body": "uname -s\n", + "description": "OS kernel name (i.e. Linux)" + }, + "system.kernel-release": { + "prefix": "system kernel release", + "body": "uname -r\n", + "description": "OS kernel release (i.e. 4.4.0-140-generic)" + }, + "system.memory-info": { + "prefix": "system memory info", + "body": "sysMemory${1|MemTotal,MemFree,MemAvailable,Cached,Buffers,Active,Inactive,SwapTotal,SwapFree,SwapCached|}=`cat /proc/meminfo | grep '${1}' | awk '{print \\$2}' | head -n 1`\n", + "description": "System memory information in kilobytes (KB)" + }, + "system.process-id": { + "prefix": "process ID", + "body": "pgrep ${1:process_name}\n", + "description": "Find process id (PID)" + }, + "system.process-kill": { + "prefix": "process kill", + "body": "sudo kill -9 `pgrep ${1:process_name}`\n", + "description": "Kill process by name" + }, + "system.process-list": { + "prefix": "process list", + "body": "ps -A\n", + "description": "List processes" + }, + "system.processor-architecture": { + "prefix": "system processor architecture", + "body": "lscpu | grep 'Architecture' |awk '{print \\$2}' | head -n 1\n", + "description": "Processor architecture (i.e. x86_64)" + }, + "system.processor-count": { + "prefix": "system processor count", + "body": "lscpu | grep 'CPU(s)' |awk '{print \\$2}' | head -n 1\n", + "description": "Processor count (cores)" + }, + "system.processor-model": { + "prefix": "system processor model", + "body": "lscpu | grep 'Model name' |cut -d ' ' -f 3- | sed -e 's/^[[:space:]]*//'\n", + "description": "Processor model name (i.e. Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz)" + }, + "system.processor-type": { + "prefix": "system processor type", + "body": "uname -p\n", + "description": "OS processor type (i.e. x86_64)" + }, + "system.service-manage": { + "prefix": "service manage", + "body": "sudo systemctl ${1|enable,disable,start,stop,reload,restart,status|} ${2:service}\n", + "description": "Manage service operations" + }, + "system.uptime": { + "prefix": "system uptime", + "body": "sys_uptime=`uptime | cut -d ' ' -f2`\n", + "description": "System uptime (hh:mm:ss)" + } +} \ No newline at end of file From 76b539b8ac8a46253856439bdbec0fc2cac5fef7 Mon Sep 17 00:00:00 2001 From: remisa Date: Sun, 24 May 2020 00:35:27 +0430 Subject: [PATCH 2/2] Ready for 4.5.0 :hammer: --- .vscodeignore | 1 + CHANGELOG.md | 6 ++ COMMANDS.md | 86 ++++++++++++------- Dockerfile | 16 ++++ README.md | 9 +- nsroot/README.md | 20 ++++- nsroot/archive/compress-tar-gz.json | 2 +- nsroot/archive/compress-tar-xz.json | 5 ++ nsroot/archive/decompress-tar-xz.json | 5 ++ nsroot/{lang => internal}/for-i-j.json | 0 nsroot/{lang => internal}/for-i.json | 0 .../{lang => internal}/for-in-collection.json | 0 nsroot/{lang => internal}/for-in-column.json | 0 nsroot/{lang => internal}/if-elif-else.json | 0 nsroot/{lang => internal}/if-not.json | 0 nsroot/{lang => internal}/if.json | 0 nsroot/{lang => internal}/switch.json | 0 nsroot/{lang => internal}/until.json | 0 nsroot/{lang => internal}/while.json | 0 package.json | 2 +- snippets/snippets.json | 60 +++++++------ 21 files changed, 145 insertions(+), 67 deletions(-) create mode 100644 Dockerfile create mode 100644 nsroot/archive/compress-tar-xz.json create mode 100644 nsroot/archive/decompress-tar-xz.json rename nsroot/{lang => internal}/for-i-j.json (100%) rename nsroot/{lang => internal}/for-i.json (100%) rename nsroot/{lang => internal}/for-in-collection.json (100%) rename nsroot/{lang => internal}/for-in-column.json (100%) rename nsroot/{lang => internal}/if-elif-else.json (100%) rename nsroot/{lang => internal}/if-not.json (100%) rename nsroot/{lang => internal}/if.json (100%) rename nsroot/{lang => internal}/switch.json (100%) rename nsroot/{lang => internal}/until.json (100%) rename nsroot/{lang => internal}/while.json (100%) diff --git a/.vscodeignore b/.vscodeignore index 4ccd1fb..aa26f1e 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -5,5 +5,6 @@ _config.yml .gitattributes .gitignore build.js +Dockerfile publish.sh test.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index a7566ee..95db083 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 4.5.0 + +- Renice process and sub processes. [PR](https://github.com/yousefvand/shellman/pull/17) by [@jakiro2017](https://github.com/jakiro2017). +- `archive...` + - Compress/decompress file/directory to/from `.tar.xz` + ## 4.4.0 - Fixed issue [#13](https://github.com/yousefvand/shellman/issues/13). Thanks to [@wangyuew](https://github.com/wangyuew). diff --git a/COMMANDS.md b/COMMANDS.md index 918341d..9d87f81 100644 --- a/COMMANDS.md +++ b/COMMANDS.md @@ -4,8 +4,12 @@ - [archive compress tar.gz](#archive-compress-tar.gz) + - [archive compress tar.xz](#archive-compress-tar.xz) + - [archive decompress tar.gz](#archive-decompress-tar.gz) + - [archive decompress tar.xz](#archive-decompress-tar.xz) + - array - [array all](#array-all) @@ -270,15 +274,7 @@ - [if int !=](#if-int-!=) -- ip - - - [ips](#ips) - - - [ip info](#ip-info) - - - [ip public](#ip-public) - -- lang +- internal - [for ij](#for-ij) @@ -300,6 +296,14 @@ - [while](#while) +- ip + + - [ips](#ips) + + - [ip info](#ip-info) + + - [ip public](#ip-public) + - math - [math +](#math-+) @@ -472,6 +476,14 @@ compress file/folder to a .tar.gz file [↑](#Commands) tar -czvf /path/to/archive.tar.gz /path/to/directory-or-file ``` +## `archive compress tar.xz` + +compress file/folder to a .tar.xz file [↑](#Commands) + +```bash +tar -cJf /path/to/archive.tar.xz /path/to/directory-or-file +``` + ## `archive decompress tar.gz` decompress a .tar.gz file to specified path [↑](#Commands) @@ -480,6 +492,14 @@ decompress a .tar.gz file to specified path [↑](#Commands) tar -C /extract/to/path -xzvf /path/to/archive.tar.gz ``` +## `archive decompress tar.xz` + +decompress a .tar.xz file to specified path [↑](#Commands) + +```bash +tar -C /extract/to/path -xf /path/to/archive.tar.xz +``` + ## `array all` all array elements [↑](#Commands) @@ -1666,30 +1686,6 @@ if (( int1 != ${2:int2} )); then fi ``` -## `ips` - -Array of local IPs [↑](#Commands) - -```bash -IPS=`hostname -I` -``` - -## `ip info` - -public ip information [↑](#Commands) - -```bash -echo `curl -s ipinfo.io/${1|ip,city,region,country,loc,postal,org|}` -``` - -## `ip public` - -public ip address [↑](#Commands) - -```bash -PUBLIC_IP=`curl -s ${1|bot.whatismyipaddress.com,ident.me,ipecho.net/plain,icanhazip.com,ifconfig.me,api.ipify.org,ipinfo.io/ip|}` -``` - ## `for ij` for loop by index [↑](#Commands) @@ -1801,6 +1797,30 @@ while [ condition ]; do done ``` +## `ips` + +Array of local IPs [↑](#Commands) + +```bash +IPS=`hostname -I` +``` + +## `ip info` + +public ip information [↑](#Commands) + +```bash +echo `curl -s ipinfo.io/${1|ip,city,region,country,loc,postal,org|}` +``` + +## `ip public` + +public ip address [↑](#Commands) + +```bash +PUBLIC_IP=`curl -s ${1|bot.whatismyipaddress.com,ident.me,ipecho.net/plain,icanhazip.com,ifconfig.me,api.ipify.org,ipinfo.io/ip|}` +``` + ## `math +` add two variables [↑](#Commands) diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d8bc192 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +# TODO: build.js should work with env to get paths + +FROM node:latest + +LABEL maintainer="remisa.yousefvand@gmail.com" + +RUN mkdir /app +COPY ./build.js /apps +COPY ./package*.json /app +WORKDIR /app +RUN npm i +CMD [ "node", "build.js" ] + +# docker build -t remisa/shellman:latest . +# docker push remisa/shellman:latest +# docker run --rm -v "${PWD}":/shellman remisa/shellman:latest diff --git a/README.md b/README.md index 69bc103..9dec0aa 100644 --- a/README.md +++ b/README.md @@ -130,9 +130,8 @@ Call function which is declared by `fn...` ## Latest release Notes -### 4.4.0 +### 4.5.0 -- Fixed issue [#13](https://github.com/yousefvand/shellman/issues/13). Thanks to [@wangyuew](https://github.com/wangyuew). -- `fn/fx [version | semver] compare` - - Compare two [semver](https://semver.org) versions. Function compares first argument with the second and returns `>`, `<` or `=`. -- `string substring [count | frequency]`: Frequency of a substring in a string. You may need character escaping, for example if string is `1.2.3` and substring is `.` then substring should be `\.` when passed to command. +- Renice process and sub processes. [PR](https://github.com/yousefvand/shellman/pull/17) by [@jakiro2017](https://github.com/jakiro2017). +- `archive...` + - Compress/decompress file/directory to/from `.tar.xz` \ No newline at end of file diff --git a/nsroot/README.md b/nsroot/README.md index 34c6803..2195357 100644 --- a/nsroot/README.md +++ b/nsroot/README.md @@ -1,4 +1,20 @@ # Namespaces -- Directory structure depth is fixed to one -- Don't use dot (`.`) in file names \ No newline at end of file +`nsroot` is the root folder of namespaces and each namespace has its own folder inside it. + +Only one depth level is allowed (due to readability). + +Add new folder for a new namespace. + +Put snippet inside appropriate folder and run npm build task: + +```bash +$ npm run build +``` + +Bump version in `package.json` file according to [SemVer](https://semver.org). + +## Caution: + +- Directory structure depth is fixed to one. +- Don't use dot (`.`) in file and directory names. diff --git a/nsroot/archive/compress-tar-gz.json b/nsroot/archive/compress-tar-gz.json index 10bcf72..aa43627 100644 --- a/nsroot/archive/compress-tar-gz.json +++ b/nsroot/archive/compress-tar-gz.json @@ -2,4 +2,4 @@ "prefix": "archive compress tar.gz", "body": "tar -czvf ${1:/path/to/archive}.tar.gz ${2:/path/to/directory-or-file}\n", "description": "compress file/folder to a .tar.gz file" - } \ No newline at end of file +} diff --git a/nsroot/archive/compress-tar-xz.json b/nsroot/archive/compress-tar-xz.json new file mode 100644 index 0000000..cdb7f86 --- /dev/null +++ b/nsroot/archive/compress-tar-xz.json @@ -0,0 +1,5 @@ +{ + "prefix": "archive compress tar.xz", + "body": "tar -cJf ${1:/path/to/archive}.tar.xz ${2:/path/to/directory-or-file}\n", + "description": "compress file/folder to a .tar.xz file" +} \ No newline at end of file diff --git a/nsroot/archive/decompress-tar-xz.json b/nsroot/archive/decompress-tar-xz.json new file mode 100644 index 0000000..0f27f09 --- /dev/null +++ b/nsroot/archive/decompress-tar-xz.json @@ -0,0 +1,5 @@ +{ + "prefix": "archive decompress tar.xz", + "body": "tar -C ${1:/extract/to/path} -xf ${2:/path/to/archive}.tar.xz\n", + "description": "decompress a .tar.xz file to specified path" +} \ No newline at end of file diff --git a/nsroot/lang/for-i-j.json b/nsroot/internal/for-i-j.json similarity index 100% rename from nsroot/lang/for-i-j.json rename to nsroot/internal/for-i-j.json diff --git a/nsroot/lang/for-i.json b/nsroot/internal/for-i.json similarity index 100% rename from nsroot/lang/for-i.json rename to nsroot/internal/for-i.json diff --git a/nsroot/lang/for-in-collection.json b/nsroot/internal/for-in-collection.json similarity index 100% rename from nsroot/lang/for-in-collection.json rename to nsroot/internal/for-in-collection.json diff --git a/nsroot/lang/for-in-column.json b/nsroot/internal/for-in-column.json similarity index 100% rename from nsroot/lang/for-in-column.json rename to nsroot/internal/for-in-column.json diff --git a/nsroot/lang/if-elif-else.json b/nsroot/internal/if-elif-else.json similarity index 100% rename from nsroot/lang/if-elif-else.json rename to nsroot/internal/if-elif-else.json diff --git a/nsroot/lang/if-not.json b/nsroot/internal/if-not.json similarity index 100% rename from nsroot/lang/if-not.json rename to nsroot/internal/if-not.json diff --git a/nsroot/lang/if.json b/nsroot/internal/if.json similarity index 100% rename from nsroot/lang/if.json rename to nsroot/internal/if.json diff --git a/nsroot/lang/switch.json b/nsroot/internal/switch.json similarity index 100% rename from nsroot/lang/switch.json rename to nsroot/internal/switch.json diff --git a/nsroot/lang/until.json b/nsroot/internal/until.json similarity index 100% rename from nsroot/lang/until.json rename to nsroot/internal/until.json diff --git a/nsroot/lang/while.json b/nsroot/internal/while.json similarity index 100% rename from nsroot/lang/while.json rename to nsroot/internal/while.json diff --git a/package.json b/package.json index 97dbc92..aa84284 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "shellman", "displayName": "shellman", "description": "Bash script snippet", - "version": "4.4.0", + "version": "4.5.0", "publisher": "Remisa", "icon": "images/icon.png", "license": "SEE LICENSE IN LICENSE.md", diff --git a/snippets/snippets.json b/snippets/snippets.json index 80cc785..ba6dc3d 100644 --- a/snippets/snippets.json +++ b/snippets/snippets.json @@ -4,11 +4,21 @@ "body": "tar -czvf ${1:/path/to/archive}.tar.gz ${2:/path/to/directory-or-file}\n", "description": "compress file/folder to a .tar.gz file" }, + "archive.compress-tar-xz": { + "prefix": "archive compress tar.xz", + "body": "tar -cJf ${1:/path/to/archive}.tar.xz ${2:/path/to/directory-or-file}\n", + "description": "compress file/folder to a .tar.xz file" + }, "archive.decompress-tar-gz": { "prefix": "archive decompress tar.gz", "body": "tar -C ${1:/extract/to/path} -xzvf ${2:/path/to/archive}.tar.gz\n", "description": "decompress a .tar.gz file to specified path" }, + "archive.decompress-tar-xz": { + "prefix": "archive decompress tar.xz", + "body": "tar -C ${1:/extract/to/path} -xf ${2:/path/to/archive}.tar.xz\n", + "description": "decompress a .tar.xz file to specified path" + }, "array.all-elements": { "prefix": "array all", "body": "${myArray[@]}\n", @@ -957,22 +967,7 @@ ], "description": "if integers are not equal" }, - "ip.array-of-local": { - "prefix": "ips", - "body": "IPS=`hostname -I`\n", - "description": "Array of local IPs" - }, - "ip.info": { - "prefix": "ip info", - "body": "echo `curl -s ipinfo.io/${1|ip,city,region,country,loc,postal,org|}`\n", - "description": "public ip information" - }, - "ip.public-address": { - "prefix": "ip public", - "body": "PUBLIC_IP=`curl -s ${1|bot.whatismyipaddress.com,ident.me,ipecho.net/plain,icanhazip.com,ifconfig.me,api.ipify.org,ipinfo.io/ip|}`\n", - "description": "public ip address" - }, - "lang.for-i-j": { + "internal.for-i-j": { "prefix": "for ij", "body": [ "for((i=0;i<${1:n};i++)); do", @@ -983,7 +978,7 @@ ], "description": "for loop by index" }, - "lang.for-i": { + "internal.for-i": { "prefix": "for i", "body": [ "for((i=0;i<${1:n};i++)); do", @@ -992,7 +987,7 @@ ], "description": "for loop by index" }, - "lang.for-in-collection": { + "internal.for-in-collection": { "prefix": "for in", "body": [ "for ${1:item} in {${2:a..z}}; do", @@ -1001,7 +996,7 @@ ], "description": "for loop in collection" }, - "lang.for-in-column": { + "internal.for-in-column": { "prefix": "for in column", "body": [ "for ${1:col} in `${2:docker images} | awk '{ print ${3:\\$1\":\"\\$2} }'`; do", @@ -1011,7 +1006,7 @@ ], "description": "for loop in collection" }, - "lang.if-elif-else": { + "internal.if-elif-else": { "prefix": "if", "body": [ "if [ ${1:condition} ]; then", @@ -1024,17 +1019,17 @@ ], "description": "if" }, - "lang.if-not": { + "internal.if-not": { "prefix": "iff not", "body": "[ ${1:condition} ] || ${2:command}\n", "description": "if condition is false then run command (short circuit)" }, - "lang.if": { + "internal.if": { "prefix": "iff", "body": "[ ${1:condition} ] && ${2:command}\n", "description": "if condition is true then run command (short circuit)" }, - "lang.switch": { + "internal.switch": { "prefix": "switch case", "body": [ "case \"\\$${1:item}\" in", @@ -1051,7 +1046,7 @@ ], "description": "switch case" }, - "lang.until": { + "internal.until": { "prefix": "until", "body": [ "until [ ${1:condition} ]; do", @@ -1060,7 +1055,7 @@ ], "description": "until loop" }, - "lang.while": { + "internal.while": { "prefix": "while", "body": [ "while [ ${1:condition} ]; do", @@ -1069,6 +1064,21 @@ ], "description": "while loop" }, + "ip.array-of-local": { + "prefix": "ips", + "body": "IPS=`hostname -I`\n", + "description": "Array of local IPs" + }, + "ip.info": { + "prefix": "ip info", + "body": "echo `curl -s ipinfo.io/${1|ip,city,region,country,loc,postal,org|}`\n", + "description": "public ip information" + }, + "ip.public-address": { + "prefix": "ip public", + "body": "PUBLIC_IP=`curl -s ${1|bot.whatismyipaddress.com,ident.me,ipecho.net/plain,icanhazip.com,ifconfig.me,api.ipify.org,ipinfo.io/ip|}`\n", + "description": "public ip address" + }, "math.add": { "prefix": "math +", "body": "${1:result}=\\$((${2:var1} + ${3:var2}))\n",