diff --git a/.vscode/settings.json b/.vscode/settings.json index 7dab94f..8f48908 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -37,6 +37,7 @@ "mylib", "nsroot", "pgrep", + "pidof", "proto", "quickstart", "renice", diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ebe9b7..d07575d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,18 +1,21 @@ # Change Log -## 4.6.1 +## 4.7.0 - New `Shellman ebook` release. [Download](https://github.com/yousefvand/shellman-ebook) free ebook (pdf, epub, mobi) - Fixed issues [#20](https://github.com/yousefvand/shellman/issues/20) and [#21](https://github.com/yousefvand/shellman/issues/21). +- directory + - `directory delete nested` | `directory remove nested`: delete directory and all contents. - Updated `summary` snippet to include exit codes. -- Samples: +- Added `loop` to `while` and `until` prefix. +- Added samples: - Step by step [sample script](samples/backup-tool) tutorial. ## 4.6.0 - Fixed issue [#19](https://github.com/yousefvand/shellman/issues/19) - Handle events `event ...` - - `exit`: Run commands when script exits. + - `EXIT`: Run commands when script exits. - `CTRL+C`: Run commands when script is interrupted. - Animation - Define animation frame. diff --git a/COMMANDS.md b/COMMANDS.md index f80b76a..db8efeb 100644 --- a/COMMANDS.md +++ b/COMMANDS.md @@ -60,7 +60,7 @@ - [crypto hash](#crypto-hash) -- date-time +- date - [date now dayOfMonth](#date-now-dayOfMonth) @@ -68,27 +68,21 @@ - [date now dayOfYear](#date-now-dayOfYear) - - [time seconds epoch](#time-seconds-epoch) - - - [time now local](#time-now-local) + - [date now short](#date-now-short) - [date now monthName](#date-now-monthName) - [date now monthNumber](#date-now-monthNumber) - - [date now short](#date-now-short) - - - [time now UTC](#time-now-UTC) - - [date now UTC](#date-now-UTC) - [date now year](#date-now-year) - event - - [event terminate](#event-terminate) + - [event CTRL+C](#event-CTRL+C) - - [event exit](#event-exit) + - [event EXIT](#event-EXIT) - filesystem @@ -96,6 +90,8 @@ - [directory create](#directory-create) + - [directory delete nested](#directory-delete-nested) + - [file delete](#file-delete) - [file read](#file-read) @@ -306,13 +302,13 @@ - [switch case](#switch-case) - - [until](#until) + - [loop until](#loop-until) - - [while](#while) + - [loop while](#loop-while) - ip - - [ips](#ips) + - [ip local IPs](#ip-local-IPs) - [ip info](#ip-info) @@ -338,8 +334,6 @@ - [math /](#math-/) - - [math 0.00](#math-0.00) - - [math ++](#math-++) - [math -=](#math--=) @@ -356,6 +350,8 @@ - [math ^](#math-^) + - [math 0.00](#math-0.00) + - [math random](#math-random) - [math √](#math-√) @@ -374,7 +370,7 @@ - [region](#region) - - [bash](#bash) + - [shebang](#shebang) - [sleep](#sleep) @@ -416,6 +412,14 @@ - [format reverse](#format-reverse) +- process + + - [process ID](#process-ID) + + - [process kill](#process-kill) + + - [process list](#process-list) + - string - [string concat](#string-concat) @@ -468,12 +472,6 @@ - [system memory info](#system-memory-info) - - [process ID](#process-ID) - - - [process kill](#process-kill) - - - [process list](#process-list) - - [system processor architecture](#system-processor-architecture) - [system processor count](#system-processor-count) @@ -486,6 +484,14 @@ - [system uptime](#system-uptime) +- time + + - [time seconds epoch](#time-seconds-epoch) + + - [time now local](#time-now-local) + + - [time now UTC](#time-now-UTC) + ## `archive compress tar.gz` compress file/folder to a .tar.gz file [↑](#Commands) @@ -661,7 +667,7 @@ sudo nice -n ${1|-20,-15,-10,-5,0,5,10,15,19|} command Change running process priority. n: -20 (highest priority) to 19 (lowest priority) [↑](#Commands) ```bash -for p in $(pidof "${process_name}"); do sudo renice -n ${1|-20,-15,-10,-5,0,5,10,15,19|} -p $p; done +for p in $(pidof "process_name"); do sudo renice -n ${2|-20,-15,-10,-5,0,5,10,15,19|} -p "$p"; done ``` ## `cmd` @@ -730,20 +736,12 @@ 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` +## `date now short` -current local time (24hrs/12hrs R/r) [↑](#Commands) +yyyy/mm/dd [↑](#Commands) ```bash -timeNowLocal=`date +%${1|R,r|}` +dateShort=`date -I` ``` ## `date now monthName` @@ -762,22 +760,6 @@ current month number (1..12) [↑](#Commands) monthNumber=`date +%m` ``` -## `date now short` - -yyyy/mm/dd [↑](#Commands) - -```bash -dateShort=`date -I` -``` - -## `time now UTC` - -current UTC time [↑](#Commands) - -```bash -timeNowUTC=`date -u +%R` -``` - ## `date now UTC` coordinated Universal Time [↑](#Commands) @@ -794,7 +776,7 @@ current Year [↑](#Commands) year=`date +%Y` ``` -## `event terminate,event CTRL+C` +## `event CTRL+C,event terminated` register a function (handler) to run on script termination (CTRL+C) [↑](#Commands) @@ -812,7 +794,7 @@ function on_ctrl_c() { trap on_ctrl_c SIGINT ``` -## `event exit` +## `event EXIT` register a function (handler) to run on script exit [↑](#Commands) @@ -845,12 +827,20 @@ create directory [↑](#Commands) mkdir "dirname" ``` +## `directory delete nested,directory remove nested` + +delete directory and all contents [↑](#Commands) + +```bash +rm -rf /path/to/directory +``` + ## `file delete,file remove` delete file(s) [↑](#Commands) ```bash -rm -f ./path/file +rm -f /path/to/file ``` ## `file read` @@ -893,7 +883,7 @@ EOL ## `file write` -write a file [↑](#Commands) +write to a file [↑](#Commands) ```bash echo "sample header" > ${2:/path/to/file} @@ -932,7 +922,7 @@ fi ## `if file link` -if file exists and is a symbolic link [↑](#Commands) +if given path is a symbolic link [↑](#Commands) ```bash if [ -h "$file" ]; then @@ -1916,7 +1906,7 @@ case "$item" in esac ``` -## `until` +## `loop until` until loop [↑](#Commands) @@ -1926,7 +1916,7 @@ until [ condition ]; do done ``` -## `while` +## `loop while` while loop [↑](#Commands) @@ -1936,7 +1926,7 @@ while [ condition ]; do done ``` -## `ips` +## `ip local IPs` Array of local IPs [↑](#Commands) @@ -2032,14 +2022,6 @@ divide var1 by var2 [↑](#Commands) result=$((var1 / var2)) ``` -## `math 0.00` - -math operations with up to scale decimal places precision [↑](#Commands) - -```bash -result=`echo "scale=${2|0,1,2,3,4,5,6,7,8,9|};($var1 ${4|+,-,*,/,^|} $var2)" | bc` -``` - ## `math ++` increment variable [↑](#Commands) @@ -2104,6 +2086,14 @@ exponentiate base to power [↑](#Commands) result=$((base ** power)) ``` +## `math 0.00` + +math operations with up to scale decimal places precision [↑](#Commands) + +```bash +result=`echo "scale=${2|0,1,2,3,4,5,6,7,8,9|};($var1 ${4|+,-,*,/,^|} $var2)" | bc` +``` + ## `math random` generate random integer x such as min <= x <= max [↑](#Commands) @@ -2191,7 +2181,7 @@ $0 # <<<<<<<<<<<<<<<<<<<<<<<< name <<<<<<<<<<<<<<<<<<<<<<<< ``` -## `bash,shebang` +## `shebang,bash` bash shebang [↑](#Commands) @@ -2365,6 +2355,30 @@ write in reverse [↑](#Commands) echo `tput rev`reversed text`tput sgr0` ``` +## `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 +``` + ## `string concat` concatenate two strings [↑](#Commands) @@ -2568,30 +2582,6 @@ System memory information in kilobytes (KB) [↑](#Commands) 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) @@ -2640,3 +2630,27 @@ System uptime (hh:mm:ss) [↑](#Commands) sys_uptime=`uptime | cut -d ' ' -f2` ``` +## `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) + +```bash +timeNowLocal=`date +%${1|R,r|}` +``` + +## `time now UTC` + +current UTC time [↑](#Commands) + +```bash +timeNowUTC=`date -u +%R` +``` + diff --git a/README.md b/README.md index 0b31c23..c8d9560 100644 --- a/README.md +++ b/README.md @@ -133,10 +133,13 @@ Call function which is declared by `fn...` ## Latest release Notes -### 4.6.1 +### 4.7.0 - New `Shellman ebook` release. [Download](https://github.com/yousefvand/shellman-ebook) free ebook (pdf, epub, mobi) - Fixed issues [#20](https://github.com/yousefvand/shellman/issues/20) and [#21](https://github.com/yousefvand/shellman/issues/21). +- directory + - `directory delete nested` | `directory remove nested`: delete directory and all contents. - Updated `summary` snippet to include exit codes. -- Samples: +- Added `loop` to `while` and `until` prefix. +- Added samples: - Step by step [sample script](samples/backup-tool) tutorial. diff --git a/nsroot/command/renice.json b/nsroot/command/renice.json index 30dd14b..fb16cfa 100644 --- a/nsroot/command/renice.json +++ b/nsroot/command/renice.json @@ -1,5 +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", + "body": "for p in \\$(pidof \"${1:process_name}\"); do sudo renice -n ${2|-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/date-time/day-of-month-current.json b/nsroot/date/day-of-month-current.json similarity index 100% rename from nsroot/date-time/day-of-month-current.json rename to nsroot/date/day-of-month-current.json diff --git a/nsroot/date-time/day-of-week-current.json b/nsroot/date/day-of-week-current.json similarity index 100% rename from nsroot/date-time/day-of-week-current.json rename to nsroot/date/day-of-week-current.json diff --git a/nsroot/date-time/day-of-year-current.json b/nsroot/date/day-of-year-current.json similarity index 100% rename from nsroot/date-time/day-of-year-current.json rename to nsroot/date/day-of-year-current.json diff --git a/nsroot/date-time/short.json b/nsroot/date/local-short.json similarity index 100% rename from nsroot/date-time/short.json rename to nsroot/date/local-short.json diff --git a/nsroot/date-time/month-name-current.json b/nsroot/date/month-name-current.json similarity index 100% rename from nsroot/date-time/month-name-current.json rename to nsroot/date/month-name-current.json diff --git a/nsroot/date-time/month-number-current.json b/nsroot/date/month-number-current.json similarity index 100% rename from nsroot/date-time/month-number-current.json rename to nsroot/date/month-number-current.json diff --git a/nsroot/date-time/utc.json b/nsroot/date/utc-long.json similarity index 100% rename from nsroot/date-time/utc.json rename to nsroot/date/utc-long.json diff --git a/nsroot/date-time/year-current.json b/nsroot/date/year-current.json similarity index 100% rename from nsroot/date-time/year-current.json rename to nsroot/date/year-current.json diff --git a/nsroot/event/on-ctrl-c.json b/nsroot/event/on-ctrl-c.json index ba5eeb6..b9533dd 100644 --- a/nsroot/event/on-ctrl-c.json +++ b/nsroot/event/on-ctrl-c.json @@ -1,7 +1,7 @@ { "prefix": [ - "event terminate", - "event CTRL+C" + "event CTRL+C", + "event terminated" ], "body": [ "# CTRL+C event handler", diff --git a/nsroot/event/on-exit.json b/nsroot/event/on-exit.json index 82f9408..5384a31 100644 --- a/nsroot/event/on-exit.json +++ b/nsroot/event/on-exit.json @@ -1,5 +1,5 @@ { - "prefix": "event exit", + "prefix": "event EXIT", "body": [ "# Exit event handler", "function on_exit() {", diff --git a/nsroot/filesystem/directory-delete-nested.json b/nsroot/filesystem/directory-delete-nested.json new file mode 100644 index 0000000..40db1f1 --- /dev/null +++ b/nsroot/filesystem/directory-delete-nested.json @@ -0,0 +1,8 @@ +{ + "prefix": [ + "directory delete nested", + "directory remove nested" + ], + "body": "rm -rf ${1:/path/to/directory}\n", + "description": "delete directory and all contents" +} \ No newline at end of file diff --git a/nsroot/filesystem/file-delete.json b/nsroot/filesystem/file-delete.json index e25a4f8..98ec0ae 100644 --- a/nsroot/filesystem/file-delete.json +++ b/nsroot/filesystem/file-delete.json @@ -3,6 +3,6 @@ "file delete", "file remove" ], - "body": "rm -f ${1:./path/file}\n", + "body": "rm -f ${1:/path/to/file}\n", "description": "delete file(s)" } \ No newline at end of file diff --git a/nsroot/filesystem/file-write.json b/nsroot/filesystem/file-write.json index 4ce843d..508ea8d 100644 --- a/nsroot/filesystem/file-write.json +++ b/nsroot/filesystem/file-write.json @@ -6,5 +6,5 @@ "\techo \"\\$${3:line}\" >> ${2:/path/to/file}", "done\n" ], - "description": "write a file" + "description": "write to a file" } \ 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 index 7fad0bc..9a03671 100644 --- a/nsroot/filesystem/if-file-exists-and-is-symbolic-link.json +++ b/nsroot/filesystem/if-file-exists-and-is-symbolic-link.json @@ -5,5 +5,5 @@ "\t${0:echo symbolic link}", "fi\n" ], - "description": "if file exists and is a symbolic link" + "description": "if given path is a symbolic link" } \ No newline at end of file diff --git a/nsroot/git/commit-list.json b/nsroot/git/commit-list-notpushed.json similarity index 100% rename from nsroot/git/commit-list.json rename to nsroot/git/commit-list-notpushed.json diff --git a/nsroot/internal/if-not.json b/nsroot/internal/iff-not.json similarity index 100% rename from nsroot/internal/if-not.json rename to nsroot/internal/iff-not.json diff --git a/nsroot/internal/if.json b/nsroot/internal/iff.json similarity index 100% rename from nsroot/internal/if.json rename to nsroot/internal/iff.json diff --git a/nsroot/internal/until.json b/nsroot/internal/until.json index 995127d..b8956ea 100644 --- a/nsroot/internal/until.json +++ b/nsroot/internal/until.json @@ -1,5 +1,5 @@ { - "prefix": "until", + "prefix": "loop until", "body": [ "until [ ${1:condition} ]; do", "\t${0:# body}", diff --git a/nsroot/internal/while.json b/nsroot/internal/while.json index ad3b409..f64c255 100644 --- a/nsroot/internal/while.json +++ b/nsroot/internal/while.json @@ -1,5 +1,5 @@ { - "prefix": "while", + "prefix": "loop while", "body": [ "while [ ${1:condition} ]; do", "\t${0:# body}", diff --git a/nsroot/ip/array-of-local.json b/nsroot/ip/array-of-local.json index 5d3ed35..dbde608 100644 --- a/nsroot/ip/array-of-local.json +++ b/nsroot/ip/array-of-local.json @@ -1,5 +1,5 @@ { - "prefix": "ips", + "prefix": "ip local IPs", "body": "IPS=`hostname -I`\n", "description": "Array of local IPs" } \ No newline at end of file diff --git a/nsroot/math/float.json b/nsroot/math/precision.json similarity index 100% rename from nsroot/math/float.json rename to nsroot/math/precision.json diff --git a/nsroot/misc/shebang.json b/nsroot/misc/shebang.json index 90f6a11..afba397 100644 --- a/nsroot/misc/shebang.json +++ b/nsroot/misc/shebang.json @@ -1,7 +1,7 @@ { "prefix": [ - "bash", - "shebang" + "shebang", + "bash" ], "body": "#!/usr/bin/env ${1|bash,node,perl,php,python,python3,ruby|}\n\n", "description": "bash shebang" diff --git a/nsroot/system/process-id.json b/nsroot/process/process-id.json similarity index 100% rename from nsroot/system/process-id.json rename to nsroot/process/process-id.json diff --git a/nsroot/system/process-kill.json b/nsroot/process/process-kill.json similarity index 100% rename from nsroot/system/process-kill.json rename to nsroot/process/process-kill.json diff --git a/nsroot/system/process-list.json b/nsroot/process/process-list.json similarity index 100% rename from nsroot/system/process-list.json rename to nsroot/process/process-list.json diff --git a/nsroot/date-time/epoch-seconds.json b/nsroot/time/epoch-seconds.json similarity index 100% rename from nsroot/date-time/epoch-seconds.json rename to nsroot/time/epoch-seconds.json diff --git a/nsroot/date-time/local-time-current.json b/nsroot/time/local-time-current.json similarity index 100% rename from nsroot/date-time/local-time-current.json rename to nsroot/time/local-time-current.json diff --git a/nsroot/date-time/time-utc.json b/nsroot/time/time-utc.json similarity index 100% rename from nsroot/date-time/time-utc.json rename to nsroot/time/time-utc.json diff --git a/package-lock.json b/package-lock.json index b362e8e..c6e3a0b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "shellman", - "version": "4.6.1", + "version": "4.7.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -801,4 +801,4 @@ "dev": true } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index d5b9c60..bcddd5b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "shellman", "displayName": "shellman", "description": "Bash script snippet", - "version": "4.6.1", + "version": "4.7.0", "publisher": "Remisa", "icon": "images/icon.png", "license": "SEE LICENSE IN LICENSE.md", @@ -37,4 +37,4 @@ "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 9097eda..2247c39 100644 --- a/snippets/snippets.json +++ b/snippets/snippets.json @@ -128,7 +128,7 @@ }, "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", + "body": "for p in \\$(pidof \"${1:process_name}\"); do sudo renice -n ${2|-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": { @@ -160,65 +160,50 @@ "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": { + "date.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": { + "date.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": { + "date.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.local-short": { + "prefix": "date now short", + "body": "dateShort=`date -I`\n", + "description": "yyyy/mm/dd" }, - "date-time.month-name-current": { + "date.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": { + "date.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": { + "date.utc-long": { "prefix": "date now UTC", "body": "dateUTC=`date -u`\n", "description": "coordinated Universal Time" }, - "date-time.year-current": { + "date.year-current": { "prefix": "date now year", "body": "year=`date +%Y`\n", "description": "current Year" }, "event.on-ctrl-c": { "prefix": [ - "event terminate", - "event CTRL+C" + "event CTRL+C", + "event terminated" ], "body": [ "# CTRL+C event handler", @@ -236,7 +221,7 @@ "description": "register a function (handler) to run on script termination (CTRL+C)" }, "event.on-exit": { - "prefix": "event exit", + "prefix": "event EXIT", "body": [ "# Exit event handler", "function on_exit() {", @@ -261,12 +246,20 @@ "body": "mkdir \"${1:dirname}\"\n", "description": "create directory" }, + "filesystem.directory-delete-nested": { + "prefix": [ + "directory delete nested", + "directory remove nested" + ], + "body": "rm -rf ${1:/path/to/directory}\n", + "description": "delete directory and all contents" + }, "filesystem.file-delete": { "prefix": [ "file delete", "file remove" ], - "body": "rm -f ${1:./path/file}\n", + "body": "rm -f ${1:/path/to/file}\n", "description": "delete file(s)" }, "filesystem.file-read": { @@ -313,7 +306,7 @@ "\techo \"\\$${3:line}\" >> ${2:/path/to/file}", "done\n" ], - "description": "write a file" + "description": "write to a file" }, "filesystem.find-files-or-directories": { "prefix": [ @@ -348,7 +341,7 @@ "\t${0:echo symbolic link}", "fi\n" ], - "description": "if file exists and is a symbolic link" + "description": "if given path is a symbolic link" }, "filesystem.if-file-exists": { "prefix": "if file exists", @@ -880,7 +873,7 @@ "body": "git clone https://${1:github.com}/${2:user}/${3:repository}.git\n", "description": "Clone remote repository to local machine." }, - "git.commit-list": { + "git.commit-list-notpushed": { "prefix": "git commit list notPushed", "body": "git log origin/master..HEAD\n", "description": "List non pushed commits." @@ -1139,12 +1132,12 @@ ], "description": "if" }, - "internal.if-not": { + "internal.iff-not": { "prefix": "iff not", "body": "[ ${1:condition} ] || ${2:command}\n", "description": "if condition is false then run command (short circuit)" }, - "internal.if": { + "internal.iff": { "prefix": "iff", "body": "[ ${1:condition} ] && ${2:command}\n", "description": "if condition is true then run command (short circuit)" @@ -1167,7 +1160,7 @@ "description": "switch case" }, "internal.until": { - "prefix": "until", + "prefix": "loop until", "body": [ "until [ ${1:condition} ]; do", "\t${0:# body}", @@ -1176,7 +1169,7 @@ "description": "until loop" }, "internal.while": { - "prefix": "while", + "prefix": "loop while", "body": [ "while [ ${1:condition} ]; do", "\t${0:# body}", @@ -1185,7 +1178,7 @@ "description": "while loop" }, "ip.array-of-local": { - "prefix": "ips", + "prefix": "ip local IPs", "body": "IPS=`hostname -I`\n", "description": "Array of local IPs" }, @@ -1244,11 +1237,6 @@ "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", @@ -1289,6 +1277,11 @@ "body": "${1:result}=\\$((${2:base} ** ${3:power}))\n", "description": "exponentiate base to power" }, + "math.precision": { + "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.random-number": { "prefix": "math random", "body": "${1:result}=\\$((${2:min} + RANDOM % \\$((${3:max}-${2:min}))))\n", @@ -1363,8 +1356,8 @@ }, "misc.shebang": { "prefix": [ - "bash", - "shebang" + "shebang", + "bash" ], "body": "#!/usr/bin/env ${1|bash,node,perl,php,python,python3,ruby|}\n\n", "description": "bash shebang" @@ -1485,6 +1478,21 @@ "body": "echo `tput rev`${0:reversed text}`tput sgr0`\n", "description": "write in reverse" }, + "process.process-id": { + "prefix": "process ID", + "body": "pgrep ${1:process_name}\n", + "description": "Find process id (PID)" + }, + "process.process-kill": { + "prefix": "process kill", + "body": "sudo kill -9 `pgrep ${1:process_name}`\n", + "description": "Kill process by name" + }, + "process.process-list": { + "prefix": "process list", + "body": "ps -A\n", + "description": "List processes" + }, "string.concat": { "prefix": "string concat", "body": "${0:str}=\"\\${${1:str1}}\\${${2:str2}}\"\n", @@ -1640,21 +1648,6 @@ "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", @@ -1684,5 +1677,20 @@ "prefix": "system uptime", "body": "sys_uptime=`uptime | cut -d ' ' -f2`\n", "description": "System uptime (hh:mm:ss)" + }, + "time.epoch-seconds": { + "prefix": "time seconds epoch", + "body": "timeNowSecondsEpoch=`date +%s`\n", + "description": "seconds since epoch (1970-01-01 00:00:00)" + }, + "time.local-time-current": { + "prefix": "time now local", + "body": "timeNowLocal=`date +%${1|R,r|}`\n", + "description": "current local time (24hrs/12hrs R/r)" + }, + "time.time-utc": { + "prefix": "time now UTC", + "body": "timeNowUTC=`date -u +%R`\n", + "description": "current UTC time" } } \ No newline at end of file