diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-11-06 09:29:30 +0100 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-11-06 09:29:30 +0100 |
commit | 61d5bb429488794ac178a47fa73c38322aa14c04 (patch) | |
tree | 6cd7d3510f999701b5e2f7fe10b0f790cd868243 /bin | |
parent | af9608a3a98f0ab4217da80b8d478810505801bc (diff) | |
parent | 694813e05187b5ccf144425c4bad6f5ab4f92234 (diff) |
Merge branch 'main' of db:dotfiles
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/common/ask | 38 | ||||
-rwxr-xr-x | bin/extra/aivpn | 6 | ||||
-rwxr-xr-x | bin/extra/supd | 14 | ||||
-rwxr-xr-x | bin/guiscripts/clipo | 8 | ||||
-rwxr-xr-x | bin/guiscripts/clipp | 8 | ||||
-rwxr-xr-x | bin/guiscripts/clipswap | 4 | ||||
-rwxr-xr-x | bin/guiscripts/cliptype | 2 |
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 - |