diff --git a/.config/vis/visrc.lua b/.config/vis/visrc.lua index 1f58996..436e7c3 100644 --- a/.config/vis/visrc.lua +++ b/.config/vis/visrc.lua @@ -144,21 +144,3 @@ e.subscribe(e.WIN_STATUS, function(win) set_title(win.file.name or '[No Name]') end end) - --- find root -e.subscribe(e.WIN_OPEN, function(win) - if not win.file.path then return end - local dir = win.file.path - local home = os.getenv('HOME') - if not dir:find(home) then return end - while true do - dir = dir:match('^(.+)/[^/]+$') or home - local _, find = vis:pipe(('find %s ! -path %s -prune -type d -name .git'):format(dir, dir)) - if find or dir == home then - local cmd = ('cd "%s"'):format(dir) - vis:info(cmd) - vis:command(cmd) - break - end - end -end) diff --git a/.local/bin/xdg-open b/.local/bin/xdg-open new file mode 100755 index 0000000..fa6f764 --- /dev/null +++ b/.local/bin/xdg-open @@ -0,0 +1,17 @@ +#!/bin/sh + +[ -z "$1" ] && exit + +FILEPATH="$(realpath "$1")" + +case "$(file -i "$FILEPATH")" in + ${FILEPATH}:\ text/*) + DIRPATH="$(dirname "$FILEPATH")" + while :; do + [ "$DIRPATH" = "$HOME" ] || [ -n "$(find "$DIRPATH" ! -path "$DIRPATH" -prune -type d -name .git)" ] && break + [ "$DIRPATH" = "$(dirname "$DIRPATH")" ] && DIRPATH=$HOME || DIRPATH="$(dirname "$DIRPATH")" + done + exec $TERMINAL -D "$DIRPATH" "$EDITOR" "$FILEPATH" + ;; + *) exec xdg-open "$FILEPATH" ;; +esac diff --git a/.local/share/applications/vis.desktop b/.local/share/applications/vis.desktop deleted file mode 100644 index 02362e0..0000000 --- a/.local/share/applications/vis.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Name=Vis -GenericName=Text Editor -TryExec=vis -Exec=vis %F -Terminal=true -Type=Application -Keywords=Text;editor; -Categories=Utility;TextEditor; -StartupNotify=false -MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;