summaryrefslogtreecommitdiff
path: root/.local/bin/development
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/development')
-rwxr-xr-x.local/bin/development/envrun55
-rwxr-xr-x.local/bin/development/font2svg3
-rwxr-xr-x.local/bin/development/gh-clone-all2
-rwxr-xr-x.local/bin/development/gh-repo-size (renamed from .local/bin/development/github-repo-size)0
-rwxr-xr-x.local/bin/development/ghclone5
-rwxr-xr-x.local/bin/development/gi8
-rwxr-xr-x.local/bin/development/gitpush6
-rwxr-xr-x.local/bin/development/gitweb (renamed from .local/bin/development/gitw)0
-rwxr-xr-x.local/bin/development/nx85
9 files changed, 75 insertions, 89 deletions
diff --git a/.local/bin/development/envrun b/.local/bin/development/envrun
new file mode 100755
index 0000000..aad0822
--- /dev/null
+++ b/.local/bin/development/envrun
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+help() { echo "envrun - run programs in an isolated home directory
+
+USAGE:
+ envrun [OPTION]... COMMAND
+
+OPTIONS:
+ -d ENVHOME use the ENVHOME environment directory
+ -h show this help message"; }
+
+while getopts 'd:h' o; do case "$o" in
+ d) export ENVHOME="$OPTARG" ;;
+ *) help >&2; exit ;;
+esac done
+shift $((OPTIND - 1))
+
+export HOME="${ENVHOME:-"$PWD"}"
+export XDG_CACHE_HOME="$HOME/.cache"
+export XDG_CONFIG_HOME="$HOME/.config"
+export XDG_DATA_HOME="$HOME/.local/share"
+export XDG_STATE_HOME="$HOME/.local/state"
+
+ensure_dirs() {
+ for dir in "$@"; do
+ [ -d "$dir" ] || { missing=1; break; }
+ done
+
+ [ "$missing" = 1 ] || return
+ printf "\nFollowing directories will be created.\n\n"
+ for dir in "$@"; do
+ [ -d "$dir" ] || echo "$dir/"
+ done
+
+ printf "\ncontinue? [y/N] "
+ read -r ans
+ case "$ans" in
+ y|Y) echo; mkdir -pv "$@"; echo ;;
+ *) exit ;;
+ esac
+}
+
+ensure_dirs \
+ "$XDG_CACHE_HOME" \
+ "$XDG_CONFIG_HOME" \
+ "$XDG_DATA_HOME" \
+ "$XDG_STATE_HOME"
+
+[ "$#" -lt 1 ] && {
+ echo "Please provide a command to run."
+ exit
+}
+
+"$@"
+
diff --git a/.local/bin/development/font2svg b/.local/bin/development/font2svg
new file mode 100755
index 0000000..539972d
--- /dev/null
+++ b/.local/bin/development/font2svg
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+fontforge -c "import fontforge; fontforge.open('$1').generate('${1%.*}.svg')"
diff --git a/.local/bin/development/gh-clone-all b/.local/bin/development/gh-clone-all
index d2b3cdc..fed6efe 100755
--- a/.local/bin/development/gh-clone-all
+++ b/.local/bin/development/gh-clone-all
@@ -12,5 +12,5 @@ while [ "$page" -lt "$max" ]; do
page=$(( page + 1 ))
curl "https://api.github.com/$cntx/$name/repos?page=$page&per_page=100" |
sed -E '/^\s*"clone_url": "(.*)",$/!d; s//\1/' |
- xargs -L1 echo git clone
+ xargs -L1 git clone
done
diff --git a/.local/bin/development/github-repo-size b/.local/bin/development/gh-repo-size
index 0cedd88..0cedd88 100755
--- a/.local/bin/development/github-repo-size
+++ b/.local/bin/development/gh-repo-size
diff --git a/.local/bin/development/ghclone b/.local/bin/development/ghclone
new file mode 100755
index 0000000..2e11024
--- /dev/null
+++ b/.local/bin/development/ghclone
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+URL="https://github.com/$1/${2:-$1}"
+echo "Clone URL: $URL"
+git clone "$URL"
diff --git a/.local/bin/development/gi b/.local/bin/development/gi
new file mode 100755
index 0000000..f7884a9
--- /dev/null
+++ b/.local/bin/development/gi
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+# gi (git-ignore) - open current repo's gitingore file in $EDITOR
+
+[ -f .gitignore ] && { ${EDITOR:-nvim -p} .gitignore; exit; }
+
+TOPLEVEL="$(git rev-parse --show-toplevel)" || exit
+find "$TOPLEVEL" -name ".gitignore" | xargs -r ${EDITOR:-nvim -p}
diff --git a/.local/bin/development/gitpush b/.local/bin/development/gitpush
index 7774a7b..2c503ca 100755
--- a/.local/bin/development/gitpush
+++ b/.local/bin/development/gitpush
@@ -1,12 +1,6 @@
#!/bin/sh
push_to_remote() {
- case "$(git config --get remote.origin.url)" in
- *csstudent41*) sshadd ~/.ssh/github.com_id_ed25519 ;;
- *labstudent41*) sshadd ~/.ssh/labstudent41_id_ed25519 ;;
- *vtc-tech*) sshadd ~/.ssh/vartaktechclub_id_ed25519 ;;
- esac
-
git add --all
git commit && git push -u origin
}
diff --git a/.local/bin/development/gitw b/.local/bin/development/gitweb
index 881c81c..881c81c 100755
--- a/.local/bin/development/gitw
+++ b/.local/bin/development/gitweb
diff --git a/.local/bin/development/nx b/.local/bin/development/nx
index 862be99..8305487 100755
--- a/.local/bin/development/nx
+++ b/.local/bin/development/nx
@@ -21,7 +21,7 @@ shift $((OPTIND - 1))
[ "$#" -gt 1 ] && err "too many arguments. Only one expected"
-new_script() {
+new_file() {
cat << EOF > "$1"
#!/bin/sh
@@ -47,77 +47,8 @@ EOF
chmod u+x -- "$1" || exit
}
-
-new_c_file() {
- cat << EOF > "$1"
-#include <stdio.h>
-
-int main()
-{
- printf("Hello\n");
-
- return 0;
-}
-EOF
-}
-
-
-new_cpp_file() {
- cat << EOF > "$1"
-#include <iostream>
-
-using namespace std;
-
-int main()
-{
- cout << "Hello" << endl;
-
- cin.get();
- return 0;
-}
-EOF
-}
-
-
-new_py_file() {
- cat << EOF > "$1"
-import timeit
-
-print("Finished in %fs" % timeit.timeit())
-EOF
-}
-
-
-new_java_file() {
- PATTERN="Scanner"
- VIMCMDS="normal!2n\n noh"
- cat << EOF > "$1"
-import java.util.Scanner;
-
-class ${1%.java} {
- public static void main(String args[]) {
- Scanner sc = new Scanner(System.in);
-
- System.out.println("Finished!");
- sc.close
- }
-}
-EOF
-}
-
-
file="$1"
-new_file() {
- case "$file" in
- *.c) new_c_file "$file" ;;
- *.cpp) new_cpp_file "$file" ;;
- *.py) new_py_file "$file" ;;
- *.java) new_java_file "$file" ;;
- *) new_script "$file" ;;
- esac
-}
-
if [ -f "$file" ]; then
[ ! -w "$file" ] && chmod u+rw "$file"
if [ -s "$file" ]; then
@@ -134,15 +65,5 @@ fi
ls -lF --color -- "$file"
-case "$EDITOR" in
- '') echo "$0: \$EDITOR variable not set" >&2 && exit 1 ;;
- vi|*vim*)
- VIMCONF="$(mktemp)"; export VIMCONF
- [ -n "$VIOPTS" ] && echo "set $VIOPTS" >> "$VIMCONF"
- [ -n "$PATTERN" ] && echo "/$PATTERN" >> "$VIMCONF"
- [ -n "$VIMCMDS" ] && echo "$VIMCMDS" >> "$VIMCONF"
- $EDITOR -S "$VIMCONF" "$file"
- rm -f "$VIMCONF"
- ;;
- *) $EDITOR "$file" ;;
-esac; exit
+${EDITOR} "$file"
+