commit b4aea514e569d820a4822947c10d0b410ffa7917
parent b5fc7e5f01ff876e2e96f350f8ad2db0a97b1358
Author: GeaRSiX <gearsix@tuta.io>
Date: Wed, 1 Jul 2020 21:02:40 +0100
Merge branch 'master' of https://notabug.org/gearsix/g6scripts
Diffstat:
8 files changed, 58 insertions(+), 5 deletions(-)
diff --git a/COPYING b/COPYING
@@ -0,0 +1,9 @@
+MIT License
+Copyright (c) 2020 GeaRSiX
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
diff --git a/README.md b/README.md
@@ -28,6 +28,8 @@ I've created an install script (_another_ bash script) to help with selecting th
I'm planning to add an uninstall bash script too, currently you'll have to manually delete all the files added though.
## notes
+I personally find `gfind` and `while-true` the most useful.
+
Personally, I like to `mkdir` a ~/bin folder (make sure ~/bin is in $PATH) and ln -s for all the scripts I wanna use (e.g. below):
./install --link --dest ~/bin
@@ -61,6 +63,7 @@ Scripts related to string parsing/manipulation
### misc
- **while-true** - clear the terminal, run $1 sleep ($2 || 1), repeat forever (Ctrl+C to cancel)
+- **preview-md** - convert a markdown file ($1) to html, open if $2 == "-o" or "--open". Uses cmark by default, set conversion tool and default output destination in src.
### depreciated
diff --git a/install b/install
@@ -15,7 +15,7 @@ dir=0
all=0
force=0
verbose=0
-destination=/usr/bin # default install directory
+default_destination=/usr/local/bin/ # default install directory
source=./src/*.sh
depreciated_src=./src/depreciated/*.sh
@@ -130,13 +130,15 @@ while [[ $# -gt 0 ]]; do
;;
esac
done
-echo ""
-echo "installation"
-echo "------------"
+
## check install destination
if [[ dir -eq 0 ]]; then
- printf "install destination (default = $destination): "
+ printf "install destination (default = $default_destination): "
read destination
+ ## set to default if empty input
+ if [ -z $destination ]; then destination=$default_destination; fi
+ ## check if need root permission to r/w
+ if [ ! -w $destination ]; then echo "$destination: Permission denied"; exit 1; fi
fi
## install scripts from source
for script in $source; do
diff --git a/src/gfind.sh b/src/gfind.sh
@@ -1,6 +1,7 @@
#!/bin/sh
# gfind (grep find)
# description: find files containing string $2 in directory/file $1
+# dependencies: grep
# e.g.$ gfind dogs/ "shades"
grep -rnw $1 -e "$2" #recursive, print line #, match whole word
diff --git a/src/git-clone-bulk.sh b/src/git-clone-bulk.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+# description: clone a set of git repos to current directory
+# ARGUMENTS: git-clone-bulk repo1 repo2 repo3 ...
+
+for repo in $@; do git clone $repo; done
diff --git a/src/git-pull-all.sh b/src/git-pull-all.sh
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+# src: https://gist.github.com/grimzy/a1d3aae40412634df29cf86bb74a6f72
+# description: pull all remote branches to the local repo
+
+git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
+git fetch --all
+git pull --all
+
diff --git a/src/mkdtouch.sh b/src/mkdtouch.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+# description: mkdir $1; touch ${2, ...}
+# arguments: $1 = dir path to make; $2, ... = filenames to touch
+
+mkdir $1
+shift
+touch $@
+
diff --git a/src/preview-md.sh b/src/preview-md.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+# preview-md (preview markdown)
+# DESCRIPTION: convert a markdown file $1 to html, optionall open in a browser (if $2 == --open). Set converter in src (cmark by default).
+# e.g.$ preview-md README.md --open
+
+mdconv=cmark
+out=~/tmp/README.html
+
+${mdconv} $1 >> $out
+if [ $? -eq 0 ]; then
+ echo "succesfully converted to $out"
+ if [ ! -z $2 ] && [ $2 = "--open" ] || [ $2 = "-o" ]; then
+ xdg-open $out &>/dev/null
+ fi
+else
+ echo "$mdconv returned $?"
+fi