Skip to content

Commit

Permalink
v1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yousefvand committed Oct 25, 2018
1 parent 812c160 commit e63d8b3
Show file tree
Hide file tree
Showing 6 changed files with 266 additions and 14 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Change Log

## 1.5.0

- `region`: A region for specific purpose (functions, variables...)
- string manipluation
- `string length`: length of string in characters.
- `string trim`: remove leading and trailing white space(s).
- `string trim left`: remove leading white space(s).
- `string trim right`: remove trailing white space(s).
- `string trimm all`: remove all white space(s).
- `string replace`: find all occurences of a substrings and replace them.
- `string reverse`: reverse string characters.
- `string toLower`: convert string to lowercase.
- `string toUpper`: convert string to uppercase.
- `string substring`: part of the string from offset with [length] characters.
- `string contains`: check whether string contains substring.
- `string indexOf`: first index of substring in string.

## 1.4.0

- `assign array`: assign elements to an array.
Expand Down
144 changes: 139 additions & 5 deletions COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,30 @@

- [if string !=](#if-string-!=)

- [string length](#string-length)

- [string trim](#string-trim)

- [string trim left](#string-trim-left)

- [string trim right](#string-trim-right)

- [string trim all](#string-trim-all)

- [string replace](#string-replace)

- [string reverse](#string-reverse)

- [string toLower](#string-toLower)

- [string toUpper](#string-toUpper)

- [string substring](#string-substring)

- [string contains](#string-contains)

- [string indexOf](#string-indexOf)

- [if int =](#if-int-=)

- [if int !=](#if-int-!=)
Expand Down Expand Up @@ -138,6 +162,8 @@

- [random int](#random-int)

- [region](#region)

- [service manage](#service-manage)

- [stopwatch start](#stopwatch-start)
Expand Down Expand Up @@ -167,7 +193,7 @@
bash shebang [↑](#Commands)

```bash
#!/usr/bin/env ${1|bash,python,node|}
#!/usr/bin/env ${1|bash,node,perl,php,python,python3,ruby|}
```

## `summary`
Expand Down Expand Up @@ -335,7 +361,7 @@ if [ -n "$string" ]; then
fi
```

## `if string =`
## `if string =,string equal`

if strings are equal [↑](#Commands)

Expand All @@ -345,7 +371,7 @@ if [ "$string1" = "$string2" ]; then
fi
```

## `if string !=`
## `if string !=,string not equal`

if strings are not equal [↑](#Commands)

Expand All @@ -355,6 +381,105 @@ if [ "$string1" != "$string2" ]; then
fi
```

## `string length`

length of string in characters [↑](#Commands)

```bash
length=${#variable}
```

## `string trim`

remove leading and trailing white space(s) [↑](#Commands)

```bash
trimmed=`echo -e "${var}" | sed -e 's/^[[:space:]]*//' | sed -e 's/[[:space:]]*$//'`
```

## `string trim left`

remove leading white space(s) [↑](#Commands)

```bash
trimmed=`echo -e "${var}" | sed -e 's/^[[:space:]]*//'`
```

## `string trim right`

remove trailing white space(s) [↑](#Commands)

```bash
trimmed=`echo -e "${var}" | sed -e 's/[[:space:]]*$//'`
```

## `string trim all`

remove all white space(s) [↑](#Commands)

```bash
trimmed=`echo -e "${var}" | tr -d '[[:space:]]'`
```

## `string replace`

find all occurences of a substrings and replace them [↑](#Commands)

```bash
replaced=`echo -e "${var}" | sed -e 's/find/replace/g'`
```

## `string reverse`

reverse string characters [↑](#Commands)

```bash
reversed=`echo -e "${var}" | rev`
```

## `string toLower`

convert string to lowercase [↑](#Commands)

```bash
toLower=`echo -e "${var}" | tr '[:upper:]' '[:lower:]'`
```

## `string toUpper`

convert string to uppercase [↑](#Commands)

```bash
toUpper=`echo -e "${var}" | tr '[:lower:]' '[:upper:]'`
```

## `string substring`

part of the string from offset with length characters [↑](#Commands)

```bash
substring=`echo -e "${var:offset:length"`
```
## `string contains,if string contains`
check whether string contains substring [↑](#Commands)
```bash
if [[ "$string" = *substring* ]]; then
# body
fi
```
## `string indexOf`
first index of substring in string [↑](#Commands)
```bash
temp=${string%%"substring"*} && indexOf=`echo ${string%%"substring"*} | echo ${#temp}`
# echo $indexOf
```
## `if int =`
if integers are equal [↑](#Commands)
Expand Down Expand Up @@ -553,7 +678,7 @@ echo `curl -s ipinfo.io/${1|ip,city,region,country,loc,postal,org|}`
## `ip public`
public ip [↑](#Commands)
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|}`
Expand Down Expand Up @@ -809,6 +934,16 @@ generate random integer x such as min < x < max [&uarr;](#Commands)
echo $((min + RANDOM % $((max-min))))
```
## `region`
Comment out a special region (i.e. variable declrations [&uarr;](#Commands)
```bash
# >>>>>>>>>>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>>>>>>>>>>>
# <<<<<<<<<<<<<<<<<<<<<<<< name <<<<<<<<<<<<<<<<<<<<<<<<
```
## `service manage`
Manage service operations [&uarr;](#Commands)
Expand Down Expand Up @@ -956,4 +1091,3 @@ call scan function to scan a host over a port range [&uarr;](#Commands)
```bash
scan ${1|tcp,udp|} host fromPort toPort
```
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ Write in bold, italic, dim, reverse format.

Wide range of logical conditions which are more common in bash scripts.

`string...`

String utilities

`stopwatch...`

Start and stop, stopwatch and read elapsed time.
Expand All @@ -89,6 +93,23 @@ Call function which is declared by `fn...`

## Release Notes

### 1.5.0

- `region`: A region for specific purpose (functions, variables...)
- string manipluation
- `string length`: length of string in characters.
- `string trim`: remove leading and trailing white space(s).
- `string trim left`: remove leading white space(s).
- `string trim right`: remove trailing white space(s).
- `string trimm all`: remove all white space(s).
- `string replace`: find all occurences of a substrings and replace them.
- `string reverse`: reverse string characters.
- `string toLower`: convert string to lowercase.
- `string toUpper`: convert string to uppercase.
- `string substring`: part of the string from offset with [length] characters.
- `string contains`: check whether string contains substring.
- `string indexOf`: first index of substring in string.

### 1.4.0

- `assign array`: assign elements to an array.
Expand Down
6 changes: 5 additions & 1 deletion docgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ const snippets = JSON.parse(fs.readFileSync(path.join(__dirname, './snippets/sni
let out = '# Commands\n\n'

for (let snippetName in snippets) { // ToC
out += `- [${snippets[snippetName].prefix}](#${snippets[snippetName].prefix.split(' ').join('-')})\n\n`
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) {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "shellman",
"name": "shellman",
"displayName": "shellman",
"description": "Bash script snippet",
"version": "1.4.0",
"version": "1.5.0",
"publisher": "Remisa",
"icon": "images/icon.png",
"license": "SEE LICENSE IN LICENSE.md",
Expand All @@ -15,7 +15,7 @@
"theme": "dark"
},
"engines": {
"vscode": "0.10.x"
"vscode": "^1.28.1"
},
"categories": [
"Snippets"
Expand Down
Loading

0 comments on commit e63d8b3

Please sign in to comment.