diff --git a/.vscode/settings.json b/.vscode/settings.json index da7d6af..cf9af48 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -25,6 +25,7 @@ "gitignore", "icanhazip", "ifconfig", + "imagemagick", "ipecho", "ipify", "ipinfo", @@ -35,6 +36,7 @@ "maxdepth", "meminfo", "mobi", + "multichoice", "multiline", "mylib", "notpushed", diff --git a/CHANGELOG.md b/CHANGELOG.md index 5433d8e..48cb9df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,24 @@ # Change Log +## 5.1.0 + +- Smooth percentage for `fn progress`. +- `echo text` and `echo variable` snippet added. +- assign variable value via `variable assign` | `variable set` snippet. +- `iterate files` snippet for iterating specific file extensions inside a path. +- read/expand variable value via `var` | `variable read` | `variable expand` snippet. + +Now there is a `input` namespace for getting user input: + +- `input text`: formerly `ask question`. +- `input password`: don't show input on screen. +- `fn/fx input choice`: formerly `fn/fx options`. + ## 5.0.0 - Default command substitution to `$(command)`. - Default variable expansion to `"${variable}"`. -- Unified `TAB` ordering. +- Unified TAB ordering. - Some functions and snippets enhanced. - Descriptive aliases added to some snippets. diff --git a/COMMANDS.md b/COMMANDS.md index ead1255..a29f119 100644 --- a/COMMANDS.md +++ b/COMMANDS.md @@ -104,6 +104,8 @@ - [file write](#file-write) + - [iterate files](#iterate-files) + - [file find](#file-find) - [if directory exists](#if-directory-exists) @@ -140,10 +142,10 @@ - [fn banner simple](#fn-banner-simple) - - [fn options](#fn-options) - - [fn import](#fn-import) + - [fn options](#fn-options) + - [fn math average](#fn-math-average) - [fn math product](#fn-math-product) @@ -168,10 +170,10 @@ - [fx banner simple](#fx-banner-simple) - - [fx options](#fx-options) - - [fx import](#fx-import) + - [fx options](#fx-options) + - [fx math average](#fx-math-average) - [fx math product](#fx-math-product) @@ -276,6 +278,8 @@ - input + - [input password](#input-password) + - [input text](#input-text) - integer @@ -380,6 +384,10 @@ - [argument parsing](#argument-parsing) + - [echo text](#echo-text) + + - [echo variable](#echo-variable) + - [region](#region) - [shebang](#shebang) @@ -508,8 +516,12 @@ - variable + - [variable assign](#variable-assign) + - [variable default value](#variable-default-value) + - [var](#var) + ## `archive compress tar.gz` compress file/folder to a .tar.gz file [↑](#Commands) @@ -910,6 +922,16 @@ for line in ${lines[@]}; do done ``` +## `iterate files` + +write to a file [↑](#Commands) + +```bash +for file in ${1|'/path/to/files/',"${pathToFiles}"|}*.{jpg,png\}; do + echo "${file\"} +done +``` + ## `file find,directory find` find files (-type f) or directories (-type d) by name or pattern (*.jpg) [↑](#Commands) @@ -1155,13 +1177,30 @@ function bannerSimple() { } ``` +## `fn import` + +import functions from other shellscript files [↑](#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 +} +``` + ## `fn options,fn input choice` provide a list of options to user and return the index of selected option [↑](#Commands) ```bash -# Usage: options=("one" "two" "three"); chooseOption "Choose:" 1 "${options[@]}"; choice=$?; echo "${options[$choice]}" -function chooseOption() { +# Usage: options=("one" "two" "three"); inputChoice "Choose:" 1 "${options[@]}"; choice=$?; echo "${options[$choice]}" +function inputChoice() { echo "${1\}"; shift echo $(tput dim)-"Change selection: [up/down], Select: [ENTER]" $(tput sgr0) local selected="${1\}"; shift @@ -1203,23 +1242,6 @@ function chooseOption() { } ``` -## `fn import` - -import functions from other shellscript files [↑](#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 -} -``` - ## `fn math average` calculate average of given integers [↑](#Commands) @@ -1280,9 +1302,10 @@ function progressBar() { local current=${2\} local total=${3\} local wheelIndex=$((current % 4)) - local position=$((20 * current / total)) + local position=$((100 * current / total)) + local barPosition=$((position / 5)) - echo -ne "\r|${bar:0:$position}${space:$position:20}| ${wheel[wheelIndex]} $(($position*5))% [ ${msg} ] " + echo -ne "\r|${bar:0:$barPosition}${space:$barPosition:20}| ${wheel[wheelIndex]} ${position}% [ ${msg} ] " } ``` @@ -1403,24 +1426,24 @@ call bannerSimple function [↑](#Commands) bannerSimple "my title" "${2|*,:,+,.,x,o,$|}" ``` -## `fx options,fn input choice` +## `fx import` -call options function [↑](#Commands) +import functions from other shellscript files located in a directory (default: lib) relative to current file [↑](#Commands) ```bash -# Usage: options=("one" "two" "three"); chooseOption "Choose:" 1 "${options[@]}"; choice=$?; echo "${options[$choice]}" -options=(${2:"one" "two" "three"}) -chooseOption "Choose:" ${4|0,1,2,3,4,5,6,7,8,9|} "${${1}[@]}"; choice=$? -echo "${${1}[$choice]}" selected +# Usage: import "filename" +import "libname" ``` -## `fx import` +## `fx options,fx input choice` -import functions from other shellscript files located in a directory (default: lib) relative to current file [↑](#Commands) +call options function [↑](#Commands) ```bash -# Usage: import "filename" -import "libname" +# Usage: options=("one" "two" "three"); inputChoice "Choose:" 1 "${options[@]}"; choice=$?; echo "${options[$choice]}" +options=(${2:"one" "two" "three"}) +inputChoice "Choose:" ${4|0,1,2,3,4,5,6,7,8,9|} "${${1}[@]}"; choice=$? +echo "${${1}[$choice]}" selected ``` ## `fx math average` @@ -1834,9 +1857,19 @@ curl --request ${1|POST,PUT|} -sL \ --data ${4|'key=value',"${key}"="${value}"|} ``` +## `input password` + +get text as input from user without showing characters [↑](#Commands) + +```bash +echo "Please enter your password: " +read -s password +echo "${password\"} +``` + ## `input text,ask question` -ask question with default answer [↑](#Commands) +get text as input from user [↑](#Commands) ```bash read -ep "Question here? " -i "Default answer" answer @@ -2231,7 +2264,7 @@ result=$((min + RANDOM % $((max-min)))) square root of var up to scale decimal places [↑](#Commands) ```bash -result=$(echo "scale=${2|0,1,2,3,4,5,6,7,8,9|};sqrt(${num\})" | bc) +result=$(echo "scale=${2|0,1,2,3,4,5,6,7,8,9|};sqrt(${3|num,${num}|})" | bc) ``` ## `math -` @@ -2279,6 +2312,22 @@ done set -- "${POSITIONAL[@]}" # restore positional params ``` +## `echo text,print text` + +print text, variable or both [↑](#Commands) + +```bash +echo 'text here' +``` + +## `echo variable,print variable` + +print text, variable or both [↑](#Commands) + +```bash +echo "${variable\}" +``` + ## `region,section` comment out a special region (i.e. variable declarations) [↑](#Commands) @@ -2785,6 +2834,14 @@ timeNowUTC=$(date -u +%R) echo ${${1\}} ``` +## `variable assign,variable set` + +assign a value or another variable to a new variable [↑](#Commands) + +```bash +variable=${2|'value',"${anotherVariable}"|} +``` + ## `variable default value,assign if empty` assign default value to variable if variable is empty otherwise assign null [↑](#Commands) @@ -2792,3 +2849,11 @@ assign default value to variable if variable is empty otherwise assign null [&ua ```bash : "${variable:=defaultValue}" ``` + +## `var,variable read,variable expand` + +read the value of a variable [↑](#Commands) + +```bash +"${variable\}" +``` diff --git a/README.md b/README.md index fc83ff1..6445636 100644 --- a/README.md +++ b/README.md @@ -3,129 +3,34 @@ [![GitHub release](https://img.shields.io/github/release/yousefvand/shellman.svg?style=plastic)](https://github.com/yousefvand/shellman/releases) [![GitHub license](https://img.shields.io/github/license/yousefvand/shellman.svg?style=plastic)](https://github.com/yousefvand/shellman/blob/master/LICENSE.md) [![GitHub stars](https://img.shields.io/github/stars/yousefvand/shellman.svg?style=plastic)](https://github.com/yousefvand/shellman/stargazers) +[![GitHub issues](https://img.shields.io/github/forks/yousefvand/shellman.svg?style=plastic)](https://github.com/yousefvand/shellman/forks) [![GitHub issues](https://img.shields.io/github/issues/yousefvand/shellman.svg?style=plastic)](https://github.com/yousefvand/shellman/issues) -[![Gitter](https://img.shields.io/gitter/room/badges/shields.svg?style=plastic)](https://gitter.im/vscode-shellman/Lobby) -![Author](https://img.shields.io/badge/Author-Remisa-ff69b4.svg?style=plastic) -Shell script snippet +## Shell scripting snippet -Learn Shell Scripting with Shellman, examples included. [Download](https://github.com/yousefvand/shellman-ebook) free ebook (pdf, epub, mobi). +Learn easy Shell Scripting with `Shellman`, examples included. [Download](https://github.com/yousefvand/shellman-ebook) free ebook (pdf, epub, mobi). Reading the `Basics` part of the book is strongly recommended if you are new to `Shell Scripting`. Read [Shellman story on medium](https://medium.com/@remisa.yousefvand/shellman-reborn-f2cc948ce3fc) (3 min read). -![shellman](images/demo.gif) +![for in range](images/for.gif) -## Math example +![math square root](images/math.gif) -![shellman](images/math.gif) +![fn/fx: simple banner](images/banner.gif) -## `fn... / fx...` example +Instead of language specific syntax, here `Shell Scripting`, `Shellman` focuses on programming concepts. These concepts are grouped under `namespaces`. For example `string` namespace to name a few contains: -![shellman](images/banner.gif) +- concat +- length +- reverse +- toLower +- toUpper +- trim +- ... -## Requirements +to activate desired `snippet` you need to type `string` and select desired `snippet` from listed `snippets` i.e. `string reverse`. Using TAB key fill needed info and you are done. -- vscode -- bashdb (If you need to debug your scripts) - -## Usage - -Install extension in vscode by: - -```bash -ext install Remisa.shellman -``` - -Start typing and Shellman will provide you available commands. - -For more convenience similar commands are grouped into same prefixes. Here is an overview: - -`bash` - -Shebang should be used as the first line of your script. You can replace `bash` with any other installed scripting language like `node` or `python`. - -`argument parsing` | `parse args` - -Parse command-line arguments - -`cmd...` - -Run external commands and check if operation succeeded. - -`color...` - -Write colorful - -`directory...` - -Directory operations - -`func...` - -Snippets related to function. - -`for...` - -Iterate different collections/arrays... - -`file...` - -File operations - -`format...` - -Write in bold, italic, dim, reverse format. - -`ftp...` and `http...` - -Web methods and functionalities: GET, POST... - -`git...` - -git commands - -`if...` - -Wide range of logical conditions which are more common in shell scripts. - -`math...` - -Math operations - -`string...` - -String utilities - -`stopwatch...` - -Start and stop, stopwatch and read elapsed time. - -## `fn` / `fx` - -`fn...` - -inserts a whole function into script. Function declaration should proceed its usage. - -`fx...` - -Call function which is declared by `fn...` - -## Function usage examples - -- banner simple - - print a banner with provided title. - - example: `banner_simple "my title"` -- banner color - - print a color banner. - - example: `banner_color red "my title"` -- import - - Organize your project and reuse functions. Import functions from other shell script files. Default import directory is `lib`. This directory should be where the calling script exists and contain library files with `.sh` extension. For example if `libname.sh` contains some useful functions and exists in `lib` directory, you can import those functions into your script and call them. - - example: `import "somefile"` will import all defined functions in `somefile.sh` from `lib` directory where calling script resides. -- animation - - Create some frames with same size using `animation frame` snippet. - - Insert `animate` function using `fn animation animate` snippet. - - Call `animate` function. - - Check [sample animations](samples/animation). +Sometimes doing a job takes more than a `snippet`. `Shellman` has ready to use functions to put into your code if you type `fn`, and selected function usage is available after typing `fx`. For example the function to create a banner with desired text can be accessed via `fn banner simple` and to call this function the `snippet` is `fx banner simple`. Pass required parameters and a banner with your text would be printed. ## List of [commands](COMMANDS.md) @@ -133,10 +38,10 @@ Call function which is declared by `fn...` ## Latest release Notes -## 5.0.0 +## 5.1.0 -- Default command substitution to `$(command)`. -- Default variable expansion to `"${variable}"`. -- Unified `TAB` ordering. -- Some functions and snippets enhanced. -- Descriptive aliases added to some snippets. \ No newline at end of file +- Smooth percentage for `fn progress`. +- `echo text` and `echo variable` snippet added. +- assign variable value via `variable assign` | `variable set` snippet. +- `iterate files` snippet for iterating specific file extensions inside a path. +- read/expand variable value via `var` | `variable read` | `variable expand` snippet. diff --git a/images/banner.gif b/images/banner.gif index 2469c34..cd81c15 100644 Binary files a/images/banner.gif and b/images/banner.gif differ diff --git a/images/demo.gif b/images/demo.gif deleted file mode 100644 index b87fc50..0000000 Binary files a/images/demo.gif and /dev/null differ diff --git a/images/for.gif b/images/for.gif new file mode 100644 index 0000000..b6df3c5 Binary files /dev/null and b/images/for.gif differ diff --git a/images/math.gif b/images/math.gif index 738b741..3b6a1b3 100644 Binary files a/images/math.gif and b/images/math.gif differ diff --git a/images/stopwatch.gif b/images/stopwatch.gif deleted file mode 100644 index dcb2c58..0000000 Binary files a/images/stopwatch.gif and /dev/null differ diff --git a/nsroot/filesystem/files-iterate.json b/nsroot/filesystem/files-iterate.json new file mode 100644 index 0000000..5383b39 --- /dev/null +++ b/nsroot/filesystem/files-iterate.json @@ -0,0 +1,9 @@ +{ + "prefix": "iterate files", + "body": [ + "for file in ${1|'/path/to/files/',\"${pathToFiles}\"|}*.{jpg,png\\}; do", + "\t${2:echo \"\\${file\\}\"}", + "done\n" + ], + "description": "write to a file" +} \ No newline at end of file diff --git a/nsroot/fn-fx/fn-choice.json b/nsroot/fn-fx/fn-input-choice.json similarity index 91% rename from nsroot/fn-fx/fn-choice.json rename to nsroot/fn-fx/fn-input-choice.json index 2d5b863..3069d2b 100644 --- a/nsroot/fn-fx/fn-choice.json +++ b/nsroot/fn-fx/fn-input-choice.json @@ -4,8 +4,8 @@ "fn input choice" ], "body": [ - "# Usage: options=(\"one\" \"two\" \"three\"); chooseOption \"Choose:\" 1 \"\\${options[@]}\"; choice=\\$?; echo \"\\${options[\\$choice]}\"", - "function chooseOption() {", + "# Usage: options=(\"one\" \"two\" \"three\"); inputChoice \"Choose:\" 1 \"\\${options[@]}\"; choice=\\$?; echo \"\\${options[\\$choice]}\"", + "function inputChoice() {", "\techo \"\\${1\\}\"; shift", "\techo \\$(tput dim)-\"Change selection: [up/down], Select: [ENTER]\" \\$(tput sgr0)", "\tlocal selected=\"\\${1\\}\"; shift\n", diff --git a/nsroot/fn-fx/fn-progress.json b/nsroot/fn-fx/fn-progress.json index c5a85ee..c2f27f2 100644 --- a/nsroot/fn-fx/fn-progress.json +++ b/nsroot/fn-fx/fn-progress.json @@ -11,9 +11,10 @@ "\tlocal current=\\${2\\}", "\tlocal total=\\${3\\}", "\tlocal wheelIndex=\\$((current % 4))", - "\tlocal position=\\$((20 * current / total))", + "\tlocal position=\\$((100 * current / total))", + "\tlocal barPosition=\\$((position / 5))", "", - "\techo -ne \"\\r|\\${bar:0:\\$position}\\${space:\\$position:20}| \\${wheel[wheelIndex]} \\$((\\$position*5))% [ \\${msg} ] \"", + "\techo -ne \"\\r|\\${bar:0:\\$barPosition}\\${space:\\$barPosition:20}| \\${wheel[wheelIndex]} \\${position}% [ \\${msg} ] \"", "}\n" ], "description": "progress bar function" diff --git a/nsroot/fn-fx/fx-choice.json b/nsroot/fn-fx/fx-choice.json deleted file mode 100644 index 1395235..0000000 --- a/nsroot/fn-fx/fx-choice.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "prefix": [ - "fx options", - "fn input choice" - ], - "body": [ - "# Usage: options=(\"one\" \"two\" \"three\"); chooseOption \"Choose:\" 1 \"\\${options[@]}\"; choice=\\$?; echo \"\\${options[\\$choice]}\"", - "${1:options}=(${2:\"one\" \"two\" \"three\"})", - "chooseOption \"${3:Choose:}\" ${4|0,1,2,3,4,5,6,7,8,9|} \"\\${${1}[@]}\"; choice=\\$?", - "echo \"\\${${1}[\\$choice]}\" selected\n" - ], - "description": "call options function" -} \ No newline at end of file diff --git a/nsroot/fn-fx/fx-input-choice.json b/nsroot/fn-fx/fx-input-choice.json new file mode 100644 index 0000000..8a4be97 --- /dev/null +++ b/nsroot/fn-fx/fx-input-choice.json @@ -0,0 +1,13 @@ +{ + "prefix": [ + "fx options", + "fx input choice" + ], + "body": [ + "# Usage: options=(\"one\" \"two\" \"three\"); inputChoice \"Choose:\" 1 \"\\${options[@]}\"; choice=\\$?; echo \"\\${options[\\$choice]}\"", + "${1:options}=(${2:\"one\" \"two\" \"three\"})", + "inputChoice \"${3:Choose:}\" ${4|0,1,2,3,4,5,6,7,8,9|} \"\\${${1}[@]}\"; choice=\\$?", + "echo \"\\${${1}[\\$choice]}\" selected\n" + ], + "description": "call options function" +} \ No newline at end of file diff --git a/nsroot/input/password.json b/nsroot/input/password.json new file mode 100644 index 0000000..5848c70 --- /dev/null +++ b/nsroot/input/password.json @@ -0,0 +1,9 @@ +{ + "prefix": "input password", + "body": [ + "echo \"${1:Please enter your password: }\"", + "read -s ${2:password}", + "${3:echo \"\\${password\\}\"}\n" + ], + "description": "get text as input from user without showing characters" +} \ No newline at end of file diff --git a/nsroot/input/text.json b/nsroot/input/text.json index bdd5d04..42988e9 100644 --- a/nsroot/input/text.json +++ b/nsroot/input/text.json @@ -7,5 +7,5 @@ "read -ep \"${1:Question here? }\" -i \"${2:Default answer}\" answer", "${3:echo \"\\${answer\\}\"}\n" ], - "description": "ask question with default answer" + "description": "get text as input from user" } \ No newline at end of file diff --git a/nsroot/math/sqrt.json b/nsroot/math/sqrt.json index e941925..cf380df 100644 --- a/nsroot/math/sqrt.json +++ b/nsroot/math/sqrt.json @@ -3,6 +3,6 @@ "math √", "math sqrt" ], - "body": "${1:result}=\\$(echo \"scale=${2|0,1,2,3,4,5,6,7,8,9|};sqrt(\\${${3:num}\\})\" | bc)\n", + "body": "${1:result}=\\$(echo \"scale=${2|0,1,2,3,4,5,6,7,8,9|};sqrt(${3|num,${num}|})\" | bc)\n", "description": "square root of var up to scale decimal places" } \ No newline at end of file diff --git a/nsroot/misc/echo-text.json b/nsroot/misc/echo-text.json new file mode 100644 index 0000000..87ea6ec --- /dev/null +++ b/nsroot/misc/echo-text.json @@ -0,0 +1,8 @@ +{ + "prefix": [ + "echo text", + "print text" + ], + "body": "echo '${1:text here}'\n", + "description": "print text, variable or both" +} \ No newline at end of file diff --git a/nsroot/misc/echo-variable.json b/nsroot/misc/echo-variable.json new file mode 100644 index 0000000..d8e838b --- /dev/null +++ b/nsroot/misc/echo-variable.json @@ -0,0 +1,8 @@ +{ + "prefix": [ + "echo variable", + "print variable" + ], + "body": "echo \"\\${${1:variable}\\}\"\n", + "description": "print text, variable or both" +} \ No newline at end of file diff --git a/nsroot/variable/variable-assign.json b/nsroot/variable/variable-assign.json new file mode 100644 index 0000000..dca1191 --- /dev/null +++ b/nsroot/variable/variable-assign.json @@ -0,0 +1,8 @@ +{ + "prefix": [ + "variable assign", + "variable set" + ], + "body": "${1:variable}=${2|'value',\"${anotherVariable}\"|}\n", + "description": "assign a value or another variable to a new variable" +} \ No newline at end of file diff --git a/nsroot/variable/variable-read.json b/nsroot/variable/variable-read.json new file mode 100644 index 0000000..b328fb8 --- /dev/null +++ b/nsroot/variable/variable-read.json @@ -0,0 +1,9 @@ +{ + "prefix": [ + "var", + "variable read", + "variable expand" + ], + "body": "\"\\${${1:variable}\\}\"\n", + "description": "read the value of a variable" +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 257ba3a..96a3978 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,18 @@ { "name": "shellman", - "version": "5.0.0", + "version": "5.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "4.10.0", + "version": "5.1.0", "license": "SEE LICENSE IN LICENSE.md", "dependencies": { "ovsx": "0.1.0-next.a9154dc", "vsce": "^1.87.0" }, "devDependencies": { - "cspell": "^5.3.7", + "cspell": "^5.3.8", "path": "^0.12.7" }, "engines": { @@ -108,24 +108,24 @@ } }, "node_modules/@cspell/cspell-bundled-dicts": { - "version": "5.3.4", - "resolved": "https://registry.npmjs.org/@cspell/cspell-bundled-dicts/-/cspell-bundled-dicts-5.3.4.tgz", - "integrity": "sha512-Gx3ceqTxocxhSF/jgb6GkAQMHiycO7+R9c9KXwgk+HYG7Qs6NWYc4bcChn07d19x8wuM4a++gA65FxUh7lC+Yg==", + "version": "5.3.8", + "resolved": "https://registry.npmjs.org/@cspell/cspell-bundled-dicts/-/cspell-bundled-dicts-5.3.8.tgz", + "integrity": "sha512-cKQrpCtoiJxly8o/84BHUtEyTqY4doNLGASe2gXnoQi0Pmxrp+evtPsDxeDBqpceEsP205KuyzfeAHYYgVer1w==", "dev": true, "dependencies": { - "@cspell/dict-ada": "^1.1.1", - "@cspell/dict-aws": "^1.0.13", - "@cspell/dict-bash": "^1.0.11", + "@cspell/dict-ada": "^1.1.2", + "@cspell/dict-aws": "^1.0.14", + "@cspell/dict-bash": "^1.0.12", "@cspell/dict-companies": "^1.0.36", - "@cspell/dict-cpp": "^1.1.37", + "@cspell/dict-cpp": "^1.1.38", "@cspell/dict-cryptocurrencies": "^1.0.10", - "@cspell/dict-csharp": "^1.0.10", - "@cspell/dict-css": "^1.0.10", - "@cspell/dict-django": "^1.0.25", - "@cspell/dict-dotnet": "^1.0.24", - "@cspell/dict-elixir": "^1.0.23", - "@cspell/dict-en_us": "^1.2.39", - "@cspell/dict-en-gb": "^1.1.27", + "@cspell/dict-csharp": "^1.0.11", + "@cspell/dict-css": "^1.0.11", + "@cspell/dict-django": "^1.0.26", + "@cspell/dict-dotnet": "^1.0.25", + "@cspell/dict-elixir": "^1.0.24", + "@cspell/dict-en_us": "^1.2.40", + "@cspell/dict-en-gb": "^1.1.28", "@cspell/dict-filetypes": "^1.1.5", "@cspell/dict-fonts": "^1.0.14", "@cspell/dict-fullstack": "^1.0.36", @@ -134,7 +134,7 @@ "@cspell/dict-html": "^1.1.6", "@cspell/dict-html-symbol-entities": "^1.0.23", "@cspell/dict-java": "^1.0.22", - "@cspell/dict-latex": "^1.0.23", + "@cspell/dict-latex": "^1.0.25", "@cspell/dict-lorem-ipsum": "^1.0.22", "@cspell/dict-lua": "^1.0.16", "@cspell/dict-node": "^1.0.10", @@ -153,9 +153,9 @@ } }, "node_modules/@cspell/cspell-types": { - "version": "5.3.7", - "resolved": "https://registry.npmjs.org/@cspell/cspell-types/-/cspell-types-5.3.7.tgz", - "integrity": "sha512-3cJcxV8rJez2MLOGuCQEdMVzXUEzH6XsUr3EzO7IDCt6fK66YGTGFuDIHVya1H3xQ+EENv/o9mZh13LNBxikVg==", + "version": "5.3.8", + "resolved": "https://registry.npmjs.org/@cspell/cspell-types/-/cspell-types-5.3.8.tgz", + "integrity": "sha512-vljVDP03VRIwtc7ckAZQAwLfmRC2XGfAXRR3pUR9KN8s2bB+PQftJbbJqhqtgOiNiG42Qd9CeTadwWJnDC40XQ==", "dev": true }, "node_modules/@cspell/dict-ada": { @@ -285,9 +285,9 @@ "dev": true }, "node_modules/@cspell/dict-latex": { - "version": "1.0.24", - "resolved": "https://registry.npmjs.org/@cspell/dict-latex/-/dict-latex-1.0.24.tgz", - "integrity": "sha512-gy4nCK+zuJ6uFH/l4VRMncxApwPqN39NcDgG2dHSApuq18kOmG7B0Tgx4Bitg0+PN6LyGeElDiVu0qNIoo4dYA==", + "version": "1.0.25", + "resolved": "https://registry.npmjs.org/@cspell/dict-latex/-/dict-latex-1.0.25.tgz", + "integrity": "sha512-cEgg91Migqcp1SdVV7dUeMxbPDhxdNo6Fgq2eygAXQjIOFK520FFvh/qxyBvW90qdZbIRoU2AJpchyHfGuwZFA==", "dev": true }, "node_modules/@cspell/dict-lorem-ipsum": { @@ -625,18 +625,18 @@ } }, "node_modules/cspell": { - "version": "5.3.7", - "resolved": "https://registry.npmjs.org/cspell/-/cspell-5.3.7.tgz", - "integrity": "sha512-KNs1i/4pBejBMu536atrVJFVdKg1nBF0BZy3GoVwIMCABxkx8KuGaE7uj2JUaHFjlp1s7ICw/p50eL/FL0HerA==", + "version": "5.3.8", + "resolved": "https://registry.npmjs.org/cspell/-/cspell-5.3.8.tgz", + "integrity": "sha512-4KZMwrm1l7Vaa7v5vKJLM5NKn+nU2diOBzHBHmRzli/H3TsMeSpPcpbmBFgEBEDMbx33+yqJSMsN6D6xbQ2kNA==", "dev": true, "license": "MIT", "dependencies": { - "@cspell/cspell-types": "^5.3.7", + "@cspell/cspell-types": "^5.3.8", "chalk": "^4.1.0", "commander": "^7.1.0", "comment-json": "^4.1.0", - "cspell-glob": "^5.3.7", - "cspell-lib": "^5.3.7", + "cspell-glob": "^5.3.8", + "cspell-lib": "^5.3.8", "fs-extra": "^9.1.0", "get-stdin": "^8.0.0", "glob": "^7.1.6", @@ -653,9 +653,9 @@ } }, "node_modules/cspell-glob": { - "version": "5.3.7", - "resolved": "https://registry.npmjs.org/cspell-glob/-/cspell-glob-5.3.7.tgz", - "integrity": "sha512-YoOiFEI0fhs2XU0F9Lrg5emKHR2tCrDabG/hVjhEDKYRSN9D7Zx+2hXKFmi0ssmW38XKIqpnmtW/dye1LHffjQ==", + "version": "5.3.8", + "resolved": "https://registry.npmjs.org/cspell-glob/-/cspell-glob-5.3.8.tgz", + "integrity": "sha512-dOFotRP+QogT6WdcLHLRrqT/nFKvtZn4rXjBgJ5DI16CB2IEXTk+AqGUn/VIpQI7a64p/yNF5RccQZ11LfhW1w==", "dev": true, "dependencies": { "micromatch": "^4.0.2" @@ -665,9 +665,9 @@ } }, "node_modules/cspell-io": { - "version": "5.3.7", - "resolved": "https://registry.npmjs.org/cspell-io/-/cspell-io-5.3.7.tgz", - "integrity": "sha512-uQZed/E+mBsAxH8rW9GqYL8IqaT1Ed4FJZnK4zjIWcY3KPpNnGAywY5XtvcfQSn59WIyjhztzle06z7wGHP8Jg==", + "version": "5.3.8", + "resolved": "https://registry.npmjs.org/cspell-io/-/cspell-io-5.3.8.tgz", + "integrity": "sha512-+Xw0AWSHPtvns/keYi5iXG7vhrgU8Ebn4Cz78c150T9cKI8Rj0sJxwGa1C/5tNpiNz6YfKOnkpv1Ge+hZ4B9FA==", "dev": true, "dependencies": { "iconv-lite": "^0.6.2", @@ -678,19 +678,19 @@ } }, "node_modules/cspell-lib": { - "version": "5.3.7", - "resolved": "https://registry.npmjs.org/cspell-lib/-/cspell-lib-5.3.7.tgz", - "integrity": "sha512-jWHayjdQfpy4dhMAYfdyi33lW8X4ka/t7Bai9WNoRnhsNAzrAuMuo4FX6aiclGXpBLrnm2Por3foyPagcKd69Q==", + "version": "5.3.8", + "resolved": "https://registry.npmjs.org/cspell-lib/-/cspell-lib-5.3.8.tgz", + "integrity": "sha512-rJBAbboemxCrTRKmkXUbOliZgT3KlqHRcQ3H35SdyoJ6IWNd3/JNfcAQGw0UGGivAN/2oGB5z6T/h1CdI7z1dw==", "dev": true, "dependencies": { - "@cspell/cspell-bundled-dicts": "^5.3.4", - "@cspell/cspell-types": "^5.3.7", + "@cspell/cspell-bundled-dicts": "^5.3.8", + "@cspell/cspell-types": "^5.3.8", "comment-json": "^4.1.0", "configstore": "^5.0.1", "cosmiconfig": "^7.0.0", - "cspell-glob": "^5.3.7", - "cspell-io": "^5.3.7", - "cspell-trie-lib": "^5.3.7", + "cspell-glob": "^5.3.8", + "cspell-io": "^5.3.8", + "cspell-trie-lib": "^5.3.8", "fs-extra": "^9.1.0", "gensequence": "^3.1.1", "resolve-from": "^5.0.0", @@ -702,9 +702,9 @@ } }, "node_modules/cspell-trie-lib": { - "version": "5.3.7", - "resolved": "https://registry.npmjs.org/cspell-trie-lib/-/cspell-trie-lib-5.3.7.tgz", - "integrity": "sha512-gfm/EzYCgaCC8RvB1jAYxMDGqdmqupDALaEHExnOGJUe5ZUNEH8E7YWEsMemHOdjd9vgSFcGpecoFUFBfkKXXA==", + "version": "5.3.8", + "resolved": "https://registry.npmjs.org/cspell-trie-lib/-/cspell-trie-lib-5.3.8.tgz", + "integrity": "sha512-LcgtDyGEEJ0a1YM9HipqSNDFFyFMpV+aOwZixBeTH5x3RIgPkeKTSdGe5x03DFzM7XMyMAbSo6717TSwuQXydQ==", "dev": true, "dependencies": { "fs-extra": "^9.1.0", @@ -1483,7 +1483,6 @@ "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", "integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=", "dev": true, - "license": "MIT", "dependencies": { "process": "^0.11.1", "util": "^0.10.3" @@ -1968,24 +1967,24 @@ } }, "@cspell/cspell-bundled-dicts": { - "version": "5.3.4", - "resolved": "https://registry.npmjs.org/@cspell/cspell-bundled-dicts/-/cspell-bundled-dicts-5.3.4.tgz", - "integrity": "sha512-Gx3ceqTxocxhSF/jgb6GkAQMHiycO7+R9c9KXwgk+HYG7Qs6NWYc4bcChn07d19x8wuM4a++gA65FxUh7lC+Yg==", + "version": "5.3.8", + "resolved": "https://registry.npmjs.org/@cspell/cspell-bundled-dicts/-/cspell-bundled-dicts-5.3.8.tgz", + "integrity": "sha512-cKQrpCtoiJxly8o/84BHUtEyTqY4doNLGASe2gXnoQi0Pmxrp+evtPsDxeDBqpceEsP205KuyzfeAHYYgVer1w==", "dev": true, "requires": { - "@cspell/dict-ada": "^1.1.1", - "@cspell/dict-aws": "^1.0.13", - "@cspell/dict-bash": "^1.0.11", + "@cspell/dict-ada": "^1.1.2", + "@cspell/dict-aws": "^1.0.14", + "@cspell/dict-bash": "^1.0.12", "@cspell/dict-companies": "^1.0.36", - "@cspell/dict-cpp": "^1.1.37", + "@cspell/dict-cpp": "^1.1.38", "@cspell/dict-cryptocurrencies": "^1.0.10", - "@cspell/dict-csharp": "^1.0.10", - "@cspell/dict-css": "^1.0.10", - "@cspell/dict-django": "^1.0.25", - "@cspell/dict-dotnet": "^1.0.24", - "@cspell/dict-elixir": "^1.0.23", - "@cspell/dict-en_us": "^1.2.39", - "@cspell/dict-en-gb": "^1.1.27", + "@cspell/dict-csharp": "^1.0.11", + "@cspell/dict-css": "^1.0.11", + "@cspell/dict-django": "^1.0.26", + "@cspell/dict-dotnet": "^1.0.25", + "@cspell/dict-elixir": "^1.0.24", + "@cspell/dict-en_us": "^1.2.40", + "@cspell/dict-en-gb": "^1.1.28", "@cspell/dict-filetypes": "^1.1.5", "@cspell/dict-fonts": "^1.0.14", "@cspell/dict-fullstack": "^1.0.36", @@ -1994,7 +1993,7 @@ "@cspell/dict-html": "^1.1.6", "@cspell/dict-html-symbol-entities": "^1.0.23", "@cspell/dict-java": "^1.0.22", - "@cspell/dict-latex": "^1.0.23", + "@cspell/dict-latex": "^1.0.25", "@cspell/dict-lorem-ipsum": "^1.0.22", "@cspell/dict-lua": "^1.0.16", "@cspell/dict-node": "^1.0.10", @@ -2010,9 +2009,9 @@ } }, "@cspell/cspell-types": { - "version": "5.3.7", - "resolved": "https://registry.npmjs.org/@cspell/cspell-types/-/cspell-types-5.3.7.tgz", - "integrity": "sha512-3cJcxV8rJez2MLOGuCQEdMVzXUEzH6XsUr3EzO7IDCt6fK66YGTGFuDIHVya1H3xQ+EENv/o9mZh13LNBxikVg==", + "version": "5.3.8", + "resolved": "https://registry.npmjs.org/@cspell/cspell-types/-/cspell-types-5.3.8.tgz", + "integrity": "sha512-vljVDP03VRIwtc7ckAZQAwLfmRC2XGfAXRR3pUR9KN8s2bB+PQftJbbJqhqtgOiNiG42Qd9CeTadwWJnDC40XQ==", "dev": true }, "@cspell/dict-ada": { @@ -2142,9 +2141,9 @@ "dev": true }, "@cspell/dict-latex": { - "version": "1.0.24", - "resolved": "https://registry.npmjs.org/@cspell/dict-latex/-/dict-latex-1.0.24.tgz", - "integrity": "sha512-gy4nCK+zuJ6uFH/l4VRMncxApwPqN39NcDgG2dHSApuq18kOmG7B0Tgx4Bitg0+PN6LyGeElDiVu0qNIoo4dYA==", + "version": "1.0.25", + "resolved": "https://registry.npmjs.org/@cspell/dict-latex/-/dict-latex-1.0.25.tgz", + "integrity": "sha512-cEgg91Migqcp1SdVV7dUeMxbPDhxdNo6Fgq2eygAXQjIOFK520FFvh/qxyBvW90qdZbIRoU2AJpchyHfGuwZFA==", "dev": true }, "@cspell/dict-lorem-ipsum": { @@ -2430,17 +2429,17 @@ "dev": true }, "cspell": { - "version": "5.3.7", - "resolved": "https://registry.npmjs.org/cspell/-/cspell-5.3.7.tgz", - "integrity": "sha512-KNs1i/4pBejBMu536atrVJFVdKg1nBF0BZy3GoVwIMCABxkx8KuGaE7uj2JUaHFjlp1s7ICw/p50eL/FL0HerA==", + "version": "5.3.8", + "resolved": "https://registry.npmjs.org/cspell/-/cspell-5.3.8.tgz", + "integrity": "sha512-4KZMwrm1l7Vaa7v5vKJLM5NKn+nU2diOBzHBHmRzli/H3TsMeSpPcpbmBFgEBEDMbx33+yqJSMsN6D6xbQ2kNA==", "dev": true, "requires": { - "@cspell/cspell-types": "^5.3.7", + "@cspell/cspell-types": "^5.3.8", "chalk": "^4.1.0", "commander": "^7.1.0", "comment-json": "^4.1.0", - "cspell-glob": "^5.3.7", - "cspell-lib": "^5.3.7", + "cspell-glob": "^5.3.8", + "cspell-lib": "^5.3.8", "fs-extra": "^9.1.0", "get-stdin": "^8.0.0", "glob": "^7.1.6", @@ -2448,18 +2447,18 @@ } }, "cspell-glob": { - "version": "5.3.7", - "resolved": "https://registry.npmjs.org/cspell-glob/-/cspell-glob-5.3.7.tgz", - "integrity": "sha512-YoOiFEI0fhs2XU0F9Lrg5emKHR2tCrDabG/hVjhEDKYRSN9D7Zx+2hXKFmi0ssmW38XKIqpnmtW/dye1LHffjQ==", + "version": "5.3.8", + "resolved": "https://registry.npmjs.org/cspell-glob/-/cspell-glob-5.3.8.tgz", + "integrity": "sha512-dOFotRP+QogT6WdcLHLRrqT/nFKvtZn4rXjBgJ5DI16CB2IEXTk+AqGUn/VIpQI7a64p/yNF5RccQZ11LfhW1w==", "dev": true, "requires": { "micromatch": "^4.0.2" } }, "cspell-io": { - "version": "5.3.7", - "resolved": "https://registry.npmjs.org/cspell-io/-/cspell-io-5.3.7.tgz", - "integrity": "sha512-uQZed/E+mBsAxH8rW9GqYL8IqaT1Ed4FJZnK4zjIWcY3KPpNnGAywY5XtvcfQSn59WIyjhztzle06z7wGHP8Jg==", + "version": "5.3.8", + "resolved": "https://registry.npmjs.org/cspell-io/-/cspell-io-5.3.8.tgz", + "integrity": "sha512-+Xw0AWSHPtvns/keYi5iXG7vhrgU8Ebn4Cz78c150T9cKI8Rj0sJxwGa1C/5tNpiNz6YfKOnkpv1Ge+hZ4B9FA==", "dev": true, "requires": { "iconv-lite": "^0.6.2", @@ -2467,19 +2466,19 @@ } }, "cspell-lib": { - "version": "5.3.7", - "resolved": "https://registry.npmjs.org/cspell-lib/-/cspell-lib-5.3.7.tgz", - "integrity": "sha512-jWHayjdQfpy4dhMAYfdyi33lW8X4ka/t7Bai9WNoRnhsNAzrAuMuo4FX6aiclGXpBLrnm2Por3foyPagcKd69Q==", + "version": "5.3.8", + "resolved": "https://registry.npmjs.org/cspell-lib/-/cspell-lib-5.3.8.tgz", + "integrity": "sha512-rJBAbboemxCrTRKmkXUbOliZgT3KlqHRcQ3H35SdyoJ6IWNd3/JNfcAQGw0UGGivAN/2oGB5z6T/h1CdI7z1dw==", "dev": true, "requires": { - "@cspell/cspell-bundled-dicts": "^5.3.4", - "@cspell/cspell-types": "^5.3.7", + "@cspell/cspell-bundled-dicts": "^5.3.8", + "@cspell/cspell-types": "^5.3.8", "comment-json": "^4.1.0", "configstore": "^5.0.1", "cosmiconfig": "^7.0.0", - "cspell-glob": "^5.3.7", - "cspell-io": "^5.3.7", - "cspell-trie-lib": "^5.3.7", + "cspell-glob": "^5.3.8", + "cspell-io": "^5.3.8", + "cspell-trie-lib": "^5.3.8", "fs-extra": "^9.1.0", "gensequence": "^3.1.1", "resolve-from": "^5.0.0", @@ -2488,9 +2487,9 @@ } }, "cspell-trie-lib": { - "version": "5.3.7", - "resolved": "https://registry.npmjs.org/cspell-trie-lib/-/cspell-trie-lib-5.3.7.tgz", - "integrity": "sha512-gfm/EzYCgaCC8RvB1jAYxMDGqdmqupDALaEHExnOGJUe5ZUNEH8E7YWEsMemHOdjd9vgSFcGpecoFUFBfkKXXA==", + "version": "5.3.8", + "resolved": "https://registry.npmjs.org/cspell-trie-lib/-/cspell-trie-lib-5.3.8.tgz", + "integrity": "sha512-LcgtDyGEEJ0a1YM9HipqSNDFFyFMpV+aOwZixBeTH5x3RIgPkeKTSdGe5x03DFzM7XMyMAbSo6717TSwuQXydQ==", "dev": true, "requires": { "fs-extra": "^9.1.0", diff --git a/package.json b/package.json index 7f1cdd2..7e21c7d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "shellman", "displayName": "shellman", "description": "Shell script snippet", - "version": "5.0.0", + "version": "5.1.0", "publisher": "Remisa", "icon": "images/icon.png", "license": "SEE LICENSE IN LICENSE.md", @@ -29,7 +29,7 @@ ] }, "devDependencies": { - "cspell": "^5.3.7", + "cspell": "^5.3.8", "path": "^0.12.7" }, "scripts": { diff --git a/snippets/snippets.json b/snippets/snippets.json index 953fb9e..4bda9a1 100644 --- a/snippets/snippets.json +++ b/snippets/snippets.json @@ -328,6 +328,15 @@ ], "description": "write to a file" }, + "filesystem.files-iterate": { + "prefix": "iterate files", + "body": [ + "for file in ${1|'/path/to/files/',\"${pathToFiles}\"|}*.{jpg,png\\}; do", + "\t${2:echo \"\\${file\\}\"}", + "done\n" + ], + "description": "write to a file" + }, "filesystem.find-files-or-directories": { "prefix": [ "file find", @@ -555,14 +564,30 @@ ], "description": "function: print a banner with provided title and surrounding character" }, - "fn-fx.fn-choice": { + "fn-fx.fn-import": { + "prefix": "fn import", + "body": [ + "# Usage: import \"mylib\"", + "function import() {", + "\tlocal file=\"./${1: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-input-choice": { "prefix": [ "fn options", "fn input choice" ], "body": [ - "# Usage: options=(\"one\" \"two\" \"three\"); chooseOption \"Choose:\" 1 \"\\${options[@]}\"; choice=\\$?; echo \"\\${options[\\$choice]}\"", - "function chooseOption() {", + "# Usage: options=(\"one\" \"two\" \"three\"); inputChoice \"Choose:\" 1 \"\\${options[@]}\"; choice=\\$?; echo \"\\${options[\\$choice]}\"", + "function inputChoice() {", "\techo \"\\${1\\}\"; shift", "\techo \\$(tput dim)-\"Change selection: [up/down], Select: [ENTER]\" \\$(tput sgr0)", "\tlocal selected=\"\\${1\\}\"; shift\n", @@ -605,22 +630,6 @@ ], "description": "provide a list of options to user and return the index of selected option" }, - "fn-fx.fn-import": { - "prefix": "fn import", - "body": [ - "# Usage: import \"mylib\"", - "function import() {", - "\tlocal file=\"./${1: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": [ @@ -676,9 +685,10 @@ "\tlocal current=\\${2\\}", "\tlocal total=\\${3\\}", "\tlocal wheelIndex=\\$((current % 4))", - "\tlocal position=\\$((20 * current / total))", + "\tlocal position=\\$((100 * current / total))", + "\tlocal barPosition=\\$((position / 5))", "", - "\techo -ne \"\\r|\\${bar:0:\\$position}\\${space:\\$position:20}| \\${wheel[wheelIndex]} \\$((\\$position*5))% [ \\${msg} ] \"", + "\techo -ne \"\\r|\\${bar:0:\\$barPosition}\\${space:\\$barPosition:20}| \\${wheel[wheelIndex]} \\${position}% [ \\${msg} ] \"", "}\n" ], "description": "progress bar function" @@ -795,27 +805,27 @@ ], "description": "call bannerSimple function" }, - "fn-fx.fx-choice": { + "fn-fx.fx-import": { + "prefix": "fx import", + "body": [ + "# Usage: import \"filename\"", + "import \"${1:libname}\"\n" + ], + "description": "import functions from other shellscript files located in a directory (default: lib) relative to current file" + }, + "fn-fx.fx-input-choice": { "prefix": [ "fx options", - "fn input choice" + "fx input choice" ], "body": [ - "# Usage: options=(\"one\" \"two\" \"three\"); chooseOption \"Choose:\" 1 \"\\${options[@]}\"; choice=\\$?; echo \"\\${options[\\$choice]}\"", + "# Usage: options=(\"one\" \"two\" \"three\"); inputChoice \"Choose:\" 1 \"\\${options[@]}\"; choice=\\$?; echo \"\\${options[\\$choice]}\"", "${1:options}=(${2:\"one\" \"two\" \"three\"})", - "chooseOption \"${3:Choose:}\" ${4|0,1,2,3,4,5,6,7,8,9|} \"\\${${1}[@]}\"; choice=\\$?", + "inputChoice \"${3:Choose:}\" ${4|0,1,2,3,4,5,6,7,8,9|} \"\\${${1}[@]}\"; choice=\\$?", "echo \"\\${${1}[\\$choice]}\" selected\n" ], "description": "call options function" }, - "fn-fx.fx-import": { - "prefix": "fx import", - "body": [ - "# Usage: import \"filename\"", - "import \"${1:libname}\"\n" - ], - "description": "import functions from other shellscript files located in a directory (default: lib) relative to current file" - }, "fn-fx.fx-math-average": { "prefix": "fx math average", "body": [ @@ -1140,6 +1150,15 @@ ], "description": "send data with http POST/PUT, using curl" }, + "input.password": { + "prefix": "input password", + "body": [ + "echo \"${1:Please enter your password: }\"", + "read -s ${2:password}", + "${3:echo \"\\${password\\}\"}\n" + ], + "description": "get text as input from user without showing characters" + }, "input.text": { "prefix": [ "input text", @@ -1149,7 +1168,7 @@ "read -ep \"${1:Question here? }\" -i \"${2:Default answer}\" answer", "${3:echo \"\\${answer\\}\"}\n" ], - "description": "ask question with default answer" + "description": "get text as input from user" }, "integer.if-equal": { "prefix": "if int =", @@ -1448,7 +1467,7 @@ "math √", "math sqrt" ], - "body": "${1:result}=\\$(echo \"scale=${2|0,1,2,3,4,5,6,7,8,9|};sqrt(\\${${3:num}\\})\" | bc)\n", + "body": "${1:result}=\\$(echo \"scale=${2|0,1,2,3,4,5,6,7,8,9|};sqrt(${3|num,${num}|})\" | bc)\n", "description": "square root of var up to scale decimal places" }, "math.subtract": { @@ -1494,6 +1513,22 @@ ], "description": "parse command line arguments (flags/switches)" }, + "misc.echo-text": { + "prefix": [ + "echo text", + "print text" + ], + "body": "echo '${1:text here}'\n", + "description": "print text, variable or both" + }, + "misc.echo-variable": { + "prefix": [ + "echo variable", + "print variable" + ], + "body": "echo \"\\${${1:variable}\\}\"\n", + "description": "print text, variable or both" + }, "misc.region": { "prefix": [ "region", @@ -1914,6 +1949,14 @@ ], "description": "current UTC time" }, + "variable.variable-assign": { + "prefix": [ + "variable assign", + "variable set" + ], + "body": "${1:variable}=${2|'value',\"${anotherVariable}\"|}\n", + "description": "assign a value or another variable to a new variable" + }, "variable.variable-default-value": { "prefix": [ "variable default value", @@ -1921,5 +1964,14 @@ ], "body": ": \"\\${${1:variable}:=${2:defaultValue}}\"\n", "description": "assign default value to variable if variable is empty otherwise assign null" + }, + "variable.variable-read": { + "prefix": [ + "var", + "variable read", + "variable expand" + ], + "body": "\"\\${${1:variable}\\}\"\n", + "description": "read the value of a variable" } } \ No newline at end of file