diff --git a/misc/docopen b/misc/docopen new file mode 100755 index 0000000..a4b876c --- /dev/null +++ b/misc/docopen @@ -0,0 +1,21 @@ +#!/bin/zsh + +zparseopts -D -E h=help -help=help e+:=extension -extension+:=extension +if [[ -n "$help" ]]; then + echo "Usage: docopen [DIR [EXTENSION ...]]" + echo + echo "Searches for files in given or current dir, optionally filtered by extension" + echo "Files are shown in dmenu and selected file is opened" + exit 1 +fi + +# return all files in the current dir +# if arguments are given, each argument is taken as a file extension. only files +# which match any given extension are returned +search-docs() { + fd --type file $extension . "$@" +} + +target=$(search-docs "$@" | txmenu -i -l 50 -p 'Open Document:') + +[[ -n $target ]] && xdg-open $target diff --git a/misc/git-http-to-git b/misc/git-http-to-git new file mode 100755 index 0000000..7785293 --- /dev/null +++ b/misc/git-http-to-git @@ -0,0 +1,3 @@ +#!/bin/zsh +remote=${1:-origin} +git remote set-url $remote $(git remote get-url $remote | sed -e 's#https?://\([^/]*\)/#git@\1:#') diff --git a/misc/txmenu b/misc/txmenu new file mode 100755 index 0000000..29a6cee --- /dev/null +++ b/misc/txmenu @@ -0,0 +1,13 @@ +#!/bin/zsh + +# A simple wrapper around fzf and rofi, choosing based on if called from a terminal + +zparseopts -D -E i=ignorecase l:=rofi_lines p:=listprompt -prompt:=listprompt + +if test -t || [[ $TERM ]]; then + fzf $ignorecase ${listprompt:+--prompt} ${listprompt[2]} "$@" +elif [[ -n $DISPLAY ]]; then + dmenu $ignorecase $rofi_lines $listprompt "$@" +else + echo "Error: neither terminal nor X display" >&2 +fi diff --git a/misc/xdg-info b/misc/xdg-info new file mode 100755 index 0000000..0d1fd7c --- /dev/null +++ b/misc/xdg-info @@ -0,0 +1,17 @@ +#!/bin/zsh + +source ${$(realpath "$0"):h:h}/lib/common.zsh + +if ! exists column; then + column() { cat } +fi + +{ + echo -e "file\ttype\tdefault program" + for file in "$@"; do + mimetype=$(xdg-mime query filetype $file) + prog=$(xdg-mime query default $mimetype) + echo -e "$file\t$mimetype\t$prog" + done +} | column -t -s $'\t' + diff --git a/void/xqq b/void/xqq new file mode 100755 index 0000000..3ab45eb --- /dev/null +++ b/void/xqq @@ -0,0 +1,28 @@ +#!/bin/zsh + +zparseopts -D -E i=installed -installed=installed + +if [[ $installed ]]; then + filter-installed() { + grep -e '^\[\*\]' + } +else + filter-installed() { + cat + } +fi + +description=$( + xbps-query -Rs "$*" \ + | filter-installed \ + | fzf \ + | cut -d' ' -f 2 \ + | xargs xbps-query -R +) +{ + grep '^pkgname:' <<<$description + grep '^pkgver:' <<<$description + grep '^short_desc:' <<<$description + grep -v '^pkgname:\|^pkgver:\|^short_desc:' <<<$description + +}| sed -e 's/^\([^:]*:\)/\x1B[33m\1\x1B[0m/' | $PAGER