Several new scripts added
This commit is contained in:
parent
1809ffacb3
commit
cdbcc9692a
5 changed files with 82 additions and 0 deletions
21
misc/docopen
Executable file
21
misc/docopen
Executable file
|
@ -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
|
3
misc/git-http-to-git
Executable file
3
misc/git-http-to-git
Executable file
|
@ -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:#')
|
13
misc/txmenu
Executable file
13
misc/txmenu
Executable file
|
@ -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
|
17
misc/xdg-info
Executable file
17
misc/xdg-info
Executable file
|
@ -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'
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue