Skip to content

Instantly share code, notes, and snippets.

@lecram
Last active January 3, 2016 14:03
Show Gist options
  • Save lecram/6510602c61707ec34349 to your computer and use it in GitHub Desktop.
Save lecram/6510602c61707ec34349 to your computer and use it in GitHub Desktop.
#! /bin/sh
cmd="$(match "$(realpath "$1")")"
printf "create '%s'\\n" "$cmd" | nc -U /tmp/dvtm-sock
#! /bin/sh
fifo=/tmp/dvtm-fifo
sock=/tmp/dvtm-sock
rm -f "$sock" "$fifo"
mkfifo "$fifo"
nc -dlkU "$sock" > "$fifo" &
server=$!
dvtm -c "$fifo"
kill $server
rm -f "$sock" "$fifo"
#! /bin/sh
case "$1" in
*.htm|*.html)
fmt="elinks %s" ;;
*.pdf|*.xps|*.cbz|*.epub)
fmt="mutool draw -F txt %s | less" ;;
*.ogg|*.flac|*.wav|*.mp3)
fmt="play %s" ;;
*.[1-9])
fmt="man -l %s" ;;
*.c|*.h|*.sh|*.lua|*.py|*.ml|*[Mm]akefile)
fmt="vim %s" ;;
*)
fmt="less %s"
esac
printf "$fmt" "\"$1\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment