summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/common/ask38
-rwxr-xr-xbin/extra/aivpn6
-rwxr-xr-xbin/extra/supd14
-rwxr-xr-xbin/guiscripts/clipo8
-rwxr-xr-xbin/guiscripts/clipp8
-rwxr-xr-xbin/guiscripts/clipswap4
-rwxr-xr-xbin/guiscripts/cliptype2
7 files changed, 26 insertions, 54 deletions
diff --git a/bin/common/ask b/bin/common/ask
index 9fb04ce..95530f5 100755
--- a/bin/common/ask
+++ b/bin/common/ask
@@ -1,36 +1,4 @@
#!/bin/sh
-
-# requirements
-which pass jq > /dev/null ||
- exit 1
-
-# input
-test -z "${inp:=$@}" &&
- inp="$(cat /dev/stdin)"
-
-# \n\t -> ' ' && "->'
-prompt="$(echo "$inp" | tr "\n\t\"" " '")"
-test -z "$prompt" && exit 1
-
-API_KEY="$(pass tokens/openai-api)"
-model="text-davinci-003"
-tokens="1024"
-temperature=0
-
-data=$(echo \
-'{
- "prompt": "'"$prompt"'",
- "model": "'"$model"'",
- "max_tokens": '$tokens',
- "temperature": '$temperature'
-}')
-
-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')
-
-# remove newline
-echo "${output:1}"
+which tgpt >/dev/null || exit 1
+[ "${inp:=$@}" ] || inp="$(cat /dev/stdin)"
+tgpt "$inp"
diff --git a/bin/extra/aivpn b/bin/extra/aivpn
index fd72ffb..3c87ce8 100755
--- a/bin/extra/aivpn
+++ b/bin/extra/aivpn
@@ -33,9 +33,3 @@ ssh vm "rasdial \"vpn.student.ehb.be\""
ssh -f -N \
-L 2222:10.2.160.41:22 \
vm
-
-ssh -t \
- -L 8188:localhost:8188 \
- vm \
- ssh -N -L 8188:localhost:8188 luca@10.2.160.41
-logn "[8188], [2222]"
diff --git a/bin/extra/supd b/bin/extra/supd
index c7e4e8c..9a5ce0c 100755
--- a/bin/extra/supd
+++ b/bin/extra/supd
@@ -20,19 +20,19 @@ do
(
cd "$dir" || return
# is git dir
- git rev-parse > /dev/null 2>&1 || return
- printf '%s: ' "$dir" | >&2 sed "s#$HOME#~#"
- if git "${1:-fetch}" > /dev/null 2>&1
+ if ! git rev-parse > /dev/null 2>&1
then
- printf 'o'
- else
printf 'x\n'
- return
+ exit
fi
+ printf '%s: ' "$dir" | >&2 sed "s#$HOME#~#"
+ git "${1:-fetch}" > /dev/null 2>&1 &&
+ printf 'o' ||
+ printf 'x'
# Show remote state
printf ' %s%s\n' "$(git status --short 2> /dev/null |
awk 'NR==1 {print "(" $1 ")"}')" "$(git branch -v 2>/dev/null |
awk -F '[][]' '/^\*/ {print $2}' |
- sed 's/ahead/↑ /;s/behind/↓ /;s/[^↓↑]*/ /g')"
+ sed 's/ahead/↑ /;s/behind/↓ /;s/[^↓↑]*//g')"
)
done
diff --git a/bin/guiscripts/clipo b/bin/guiscripts/clipo
index e3ae714..39994f9 100755
--- a/bin/guiscripts/clipo
+++ b/bin/guiscripts/clipo
@@ -1,4 +1,6 @@
#!/bin/sh
-[ "$WAYLAND_DISPLAY" ] &&
- wl-paste -n ||
- xclip -o -selection clipboard -r
+[ "$1" = "-p" ] && arg='primary'
+if [ "$WAYLAND_DISPLAY" ]
+then wl-paste -n ${1}
+else xclip -o -selection "${arg:-clipboard}" -r
+fi
diff --git a/bin/guiscripts/clipp b/bin/guiscripts/clipp
index 538f69b..c9e4f51 100755
--- a/bin/guiscripts/clipp
+++ b/bin/guiscripts/clipp
@@ -1,4 +1,6 @@
#!/bin/sh
-[ "$WAYLAND_DISPLAY" ] &&
- wl-copy -n ||
- xclip -selection clipboard -r
+[ "$1" = "-p" ] && arg='primary'
+if [ "$WAYLAND_DISPLAY" ]
+then wl-copy -n $1
+else xclip -selection "${arg:-clipboard}" -r
+fi
diff --git a/bin/guiscripts/clipswap b/bin/guiscripts/clipswap
new file mode 100755
index 0000000..1cae135
--- /dev/null
+++ b/bin/guiscripts/clipswap
@@ -0,0 +1,4 @@
+#!/bin/sh
+paste="$(clipo)"
+clipo -p | clipp
+printf '%s' "$paste" | clipp -p
diff --git a/bin/guiscripts/cliptype b/bin/guiscripts/cliptype
new file mode 100755
index 0000000..e6ac093
--- /dev/null
+++ b/bin/guiscripts/cliptype
@@ -0,0 +1,2 @@
+#!/bin/sh
+clipo | ydotool type -f -