Commit Diff


commit - 7343e43583e876c70775a3bb019f42cdf61dd47c
commit + c68761153b8b771dbd18c015f8bf3b174c5f21cc
blob - /dev/null
blob + b666e4e7acee0eb80471a4ed9dfb6344aa95ab09 (mode 644)
--- /dev/null
+++ FAQ.md
@@ -0,0 +1,69 @@
+# Frequently Asked Questions
+
+## How to use Rover to change the current directory of a shell?
+
+Rover cannot change  the working directory of its  calling shell directly.
+However, we can use the option `--save-cwd` to write the last visited path
+to a temporary file. Then we can `cd` to that path from the shell itself.
+
+The following shell script can be used to automate this mechanism.
+Note that it needs to be sourced directly from the shell.
+
+```
+#! /bin/sh
+
+# Based on ranger launcher.
+
+# Usage:
+#     . ./cdrover.sh [/path/to/rover]
+
+tempfile="$(mktemp 2> /dev/null || printf "/tmp/rover-cwd.%s" $$)"
+if [ $# -gt 0 ]; then
+    rover="$1"
+    shift
+else
+    rover="rover"
+fi
+"$rover" --save-cwd "$tempfile" "$@"
+returnvalue=$?
+test -f "$tempfile" &&
+if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
+    cd "$(cat "$tempfile")"
+fi
+rm -f -- "$tempfile"
+return $returnvalue
+```
+
+## How to open files with appropriate applications?
+
+Rover doesn't have any built-in functionality to associate file types with
+applications. This  is delegated  to an external  tool, designated  by the
+environmental variable  `$ROVER_OPEN`. This  tool must  be a  command that
+takes a filename as argument and runs the appropriate program, opening the
+given file.
+
+As an example, the following shell script may be used as `$ROVER_OPEN`:
+
+```
+#! /bin/sh
+
+# Usage:
+#     ./open.sh /path/to/file
+
+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
+
+exec sh -c "$(printf "$fmt" "\"$1\"")"
+```
blob - 82edf7c318b306f26e16040ca42b0960a863fa85 (mode 755)
blob + /dev/null
--- rover.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-
-# Based on ranger launcher.
-#
-# Usage: ". ./rover.sh [/path/to/rover]"
-
-tempfile="$(mktemp 2> /dev/null || printf "/tmp/rover-cwd.%s" $$)"
-if [ $# -gt 0 ]; then
-    rover="$1"
-    shift
-else
-    rover="rover"
-fi
-"$rover" --save-cwd "$tempfile" "$@"
-returnvalue=$?
-test -f "$tempfile" &&
-if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
-    cd "$(cat "$tempfile")"
-fi
-rm -f -- "$tempfile"
-return $returnvalue