commit c68761153b8b771dbd18c015f8bf3b174c5f21cc from: Marcel Rodrigues date: Sat Jun 04 01:21:19 2016 UTC Add FAQ.md with information for common use cases. FAQ.md is supposed to provide extra documentation for Rover, based on common queries from users. It's a good place to put detailed information that doesn't fit the manual. The file rover.sh has been removed and an explanation for it has been added in FAQ.md instead. The same should be done for any helper script that might become worth of mention in the future. That way we don't clutter the repository with files that aren't part of a Rover basic setup. 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