xdg-open: bugfix and simplify
parent
3ad7c69a56
commit
711172dca9
|
@ -1,17 +1,17 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
[ -z "$1" ] && exit
|
case "$(file -i "$1" 2>/dev/null)" in
|
||||||
|
*": text/"* | *": application/javascript"*)
|
||||||
FILEPATH="$(realpath "$1")"
|
DIRPATH="$(dirname "$1")"
|
||||||
|
|
||||||
case "$(file -i "$FILEPATH")" in
|
|
||||||
${FILEPATH}:\ text/*)
|
|
||||||
DIRPATH="$(dirname "$FILEPATH")"
|
|
||||||
while :; do
|
while :; do
|
||||||
|
[ "$DIRPATH" = "/" ] && DIRPATH=$HOME
|
||||||
[ "$DIRPATH" = "$HOME" ] || [ -n "$(find "$DIRPATH" ! -path "$DIRPATH" -prune -type d -name .git)" ] && break
|
[ "$DIRPATH" = "$HOME" ] || [ -n "$(find "$DIRPATH" ! -path "$DIRPATH" -prune -type d -name .git)" ] && break
|
||||||
[ "$DIRPATH" = "$(dirname "$DIRPATH")" ] && DIRPATH=$HOME || DIRPATH="$(dirname "$DIRPATH")"
|
DIRPATH="$(dirname "$DIRPATH")"
|
||||||
done
|
done
|
||||||
exec $TERMINAL -D "$DIRPATH" "$EDITOR" "$FILEPATH"
|
exec $TERMINAL -D "$DIRPATH" "$EDITOR" "$1"
|
||||||
;;
|
;;
|
||||||
*) exec xdg-open "$FILEPATH" ;;
|
*": inode/directory;"*)
|
||||||
|
exec $TERMINAL -D "$1"
|
||||||
|
;;
|
||||||
|
*) exec /usr/bin/xdg-open "$1" ;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in New Issue