From 4cc03a611a20d17f43b8bb7d6f2af3341ef02ad4 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 4 Dec 2023 08:26:59 +0100 Subject: [PATCH] sh: Add default open script Simple wrapper for xdg-open functionality. Simply refers to xdg-open except if there exists mimeo on the system which it will refer to instead. So, a simple preference modificator for mimeo over xdg-open since that is my preference too. Also gave it a short name so I can do open whenever I want and don't have to tax my left hand with tying xdg. --- office/.config/task/taskopenrc | 4 ++-- office/.config/urlview/config | 2 +- qutebrowser/scripts/recently-downloaded | 12 ++++++---- sh/.config/sh/alias | 29 +++++++++---------------- sh/.local/bin/open | 8 +++++++ terminal/.config/vifm/vifmrc | 3 +++ writing/.config/pubs/pubsrc | 2 +- writing/.local/bin/rofi-bib-due | 2 +- 8 files changed, 34 insertions(+), 28 deletions(-) create mode 100755 sh/.local/bin/open diff --git a/office/.config/task/taskopenrc b/office/.config/task/taskopenrc index d78ee56..9fea550 100644 --- a/office/.config/task/taskopenrc +++ b/office/.config/task/taskopenrc @@ -4,14 +4,14 @@ taskbin = task path_ext = /usr/share/taskopen/scripts [Actions] -note_custom_ext.regex = "^Note\\.(.*)" +note_custom_ext.regex = "^Note\\.?(.*)?" note_custom_ext.command = "$EDITOR ${XDG_DATA_HOME:-$HOME/.local/share}/task/notes/$UUID.$LAST_MATCH" notes.regex = "^Note" notes.command = "$EDITOR ${XDG_DATA_HOME:-$HOME/.local/share}/task/notes/$UUID.md" links.regex = "^https?://" -links.command = "xdg-open $FILE" +links.command = "open $FILE" mail.regex = "^<.*@.*>$" mail.command = "notmuch show mid:${FILE:1:-1}" diff --git a/office/.config/urlview/config b/office/.config/urlview/config index e13370a..c351d87 100644 --- a/office/.config/urlview/config +++ b/office/.config/urlview/config @@ -1 +1 @@ -COMMAND xdg-open +COMMAND open diff --git a/qutebrowser/scripts/recently-downloaded b/qutebrowser/scripts/recently-downloaded index b2a1c18..19dd925 100755 --- a/qutebrowser/scripts/recently-downloaded +++ b/qutebrowser/scripts/recently-downloaded @@ -93,9 +93,9 @@ if [ "${#entries[@]}" -eq 0 ]; then die "Download directory »${DOWNLOAD_DIR}« empty" fi -line=$(printf '%s\n' "${entries[@]}" \ - | crop-first-column \ - | $ROFI_CMD "${ROFI_ARGS[@]}") || true +line=$(printf '%s\n' "${entries[@]}" | + crop-first-column | + $ROFI_CMD "${ROFI_ARGS[@]}") || true if [ -z "$line" ]; then exit 0 fi @@ -111,4 +111,8 @@ fi msg info "Opening »$line« (of type $filetype) with ${application%.desktop}" -xdg-open "$path" & +if type open >/dev/null 2>&1; then + open "$path" & +else + xdg-open "$path" & +fi diff --git a/sh/.config/sh/alias b/sh/.config/sh/alias index 42dda26..bc94a82 100644 --- a/sh/.config/sh/alias +++ b/sh/.config/sh/alias @@ -57,31 +57,15 @@ alias myip="curl -s icanhazip.com" if exist fzf; then # Display fuzzy-searchable history alias fzfhistory="history -l -E -D 0 | fzf --tac --height 20" - fzfman() { + fzman() { man "$(apropos --long "$1" | fzf | awk '{print $2, $1}' | tr -d '()')" } - # Fuzzy search packages to install - if exist yay; then - fzf_pkg_tool=yay - elif exist paru; then - fzf_pkg_tool=paru - elif exist pacman; then - fzf_pkg_tool=pacman - fi - # shellcheck disable=2139 # we *want* this to be done at shell startup instead of dynamically - if [ -n "$fzf_pkg_tool" ]; then - alias fzfyay="$fzf_pkg_tool -Slq | fzf -m --preview '$fzf_pkg_tool -Si {1}' | xargs -ro $fzf_pkg_tool -S" - # Fuzzy uninstall packages - alias fzfyayrns="$fzf_pkg_tool -Qeq | fzf -m --preview '$fzf_pkg_tool -Qi {1}' | xargs -ro $fzf_pkg_tool -Rns" - fi - unset fzf_pkg_tool - # ripgrep-all to fzf search through any documents if exist rga; then - fzfrga() { + fzrga() { RG_PREFIX="rga --files-with-matches" - xdg-open "$( + open "$( FZF_DEFAULT_COMMAND="$RG_PREFIX '$1'" \ fzf --sort --preview="[[ ! -z {} ]] && rga --pretty --context 5 {q} {}" \ --phony -q "$1" \ @@ -90,6 +74,13 @@ if exist fzf; then )" } fi + + # quickly fzy search a sqlite database result + if exist sqlite3; then + fzql() { + sqlite3 -header "$1" "$2" | fzf --header-lines=1 --layout=reverse --multi --prompt='fzql> ' + } + fi fi # vifm diff --git a/sh/.local/bin/open b/sh/.local/bin/open new file mode 100755 index 0000000..e3bed8f --- /dev/null +++ b/sh/.local/bin/open @@ -0,0 +1,8 @@ +#!/usr/bin/env sh +# file opener using your preferred applications + +if exist mimeo; then + mimeo "$1" +elif exist xdg-open; then + xdg-open "$1" +fi diff --git a/terminal/.config/vifm/vifmrc b/terminal/.config/vifm/vifmrc index a55a795..eef9d3c 100644 --- a/terminal/.config/vifm/vifmrc +++ b/terminal/.config/vifm/vifmrc @@ -576,6 +576,9 @@ fileviewer *.md " use custom viewer script for rest fileviewer * vifm-default-viewer %c +" use our own custom opener +filetype * open + " Syntax highlighting in preview " " Explicitly set highlight type for some extensions diff --git a/writing/.config/pubs/pubsrc b/writing/.config/pubs/pubsrc index 018dddd..a47a201 100644 --- a/writing/.config/pubs/pubsrc +++ b/writing/.config/pubs/pubsrc @@ -12,7 +12,7 @@ docsdir = ~/documents/library/doc doc_add = copy # the command to use when opening document files -open_cmd = xdg-open +open_cmd = open # which editor to use when editing bibtex files. # if using a graphical editor, use the --wait or --block option, i.e.: diff --git a/writing/.local/bin/rofi-bib-due b/writing/.local/bin/rofi-bib-due index 2577832..47406e1 100755 --- a/writing/.local/bin/rofi-bib-due +++ b/writing/.local/bin/rofi-bib-due @@ -26,4 +26,4 @@ key=$(echo "$choice" | sed -E 's/.*\((\w+)\)$/\1/') library="$(dirname "$(realpath "$BIBFILE")")/pdf" # find and open the key-associated pdf file -${FILEREADER:-xdg-open} "$(find "$library" -type f -name "$key *.pdf")" +${FILEREADER:-open} "$(find "$library" -type f -name "$key *.pdf")"