summaryrefslogtreecommitdiff
path: root/bin/common
diff options
context:
space:
mode:
Diffstat (limited to 'bin/common')
-rwxr-xr-xbin/common/ask28
-rwxr-xr-xbin/common/autofetch13
-rwxr-xr-xbin/common/fzfdir2
-rwxr-xr-xbin/common/fzfdirfile2
-rwxr-xr-xbin/common/fzffile2
-rwxr-xr-xbin/common/gign2
-rwxr-xr-xbin/common/hextorgb7
-rwxr-xr-xbin/common/wt10
8 files changed, 66 insertions, 0 deletions
diff --git a/bin/common/ask b/bin/common/ask
new file mode 100755
index 0000000..85b5f9e
--- /dev/null
+++ b/bin/common/ask
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+# Depends on passmenu
+if [ -z "$1" ]
+then
+ echo -n ">"
+ read prompt
+else
+ prompt="$@"
+fi
+
+API_KEY="$(pass tokens/openai-api)"
+
+data=$(echo \
+'{
+ "prompt": "'"$prompt"'",
+ "model": "text-davinci-003",
+ "max_tokens": 1024,
+ "temperature": 0
+}')
+
+output=$(curl -s -X POST \
+ -H 'Content-Type: application/json' \
+ -H "Authorization: Bearer $API_KEY" \
+ -d "$data" \
+ https://api.openai.com/v1/completions \
+ | jq -r '.choices[0].text')
+
+echo "${output:1}"
diff --git a/bin/common/autofetch b/bin/common/autofetch
new file mode 100755
index 0000000..3dcdc15
--- /dev/null
+++ b/bin/common/autofetch
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+GREEN='\033[0;32m'
+NC='\033[0m'
+# Fetches for git repos, meant to run at startup
+for directory in "." "installdrier" ".config" ".password-store"
+do
+ if cd ~/$directory
+ then
+ echo -ne "Fetching in ${GREEN}'~/${directory}'${NC}"
+ git fetch origin || exit 1
+ echo ", done."
+ fi
+done
diff --git a/bin/common/fzfdir b/bin/common/fzfdir
new file mode 100755
index 0000000..6ae8f6a
--- /dev/null
+++ b/bin/common/fzfdir
@@ -0,0 +1,2 @@
+#!/usr/bin/env sh
+find "${1:-$HOME}" -type \d 2> /dev/null | fzf
diff --git a/bin/common/fzfdirfile b/bin/common/fzfdirfile
new file mode 100755
index 0000000..df0e51a
--- /dev/null
+++ b/bin/common/fzfdirfile
@@ -0,0 +1,2 @@
+#!/usr/bin/env sh
+dirname "$(find "${1:-$HOME}" -type f 2> /dev/null | fzf)"
diff --git a/bin/common/fzffile b/bin/common/fzffile
new file mode 100755
index 0000000..03e39be
--- /dev/null
+++ b/bin/common/fzffile
@@ -0,0 +1,2 @@
+#!/usr/bin/env sh
+find "${1:-$HOME}" -type f 2> /dev/null | fzf
diff --git a/bin/common/gign b/bin/common/gign
new file mode 100755
index 0000000..e3ba12a
--- /dev/null
+++ b/bin/common/gign
@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+git status --porcelain=v1 | grep "^??" | cut -d' ' -f2- | sed -r 's/^["](.*)["]$/\1/' >> .gitignore
diff --git a/bin/common/hextorgb b/bin/common/hextorgb
new file mode 100755
index 0000000..b268db5
--- /dev/null
+++ b/bin/common/hextorgb
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+cat /dev/stdin \
+ | tr -d '#' | tr '[:lower:]' '[:upper:]' \
+ | sed -r 's/([0-9A-F]{2})/\1\n/g ; i ibase=16' \
+ | bc \
+ | tr '\n' ',' \
+ | sed 's/.$// ; s/.*/rgb(&)/'
diff --git a/bin/common/wt b/bin/common/wt
new file mode 100755
index 0000000..81081c8
--- /dev/null
+++ b/bin/common/wt
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+echo "$@" > /tmp/truewhile.tmp
+while true
+do
+ bash /tmp/truewhile.tmp
+ sleep 1
+ clear
+done
+rm /tmp/truewhile.tmp