#!/bin/sh # # Runs mc to select files and save the filenames to ~/.mc.sel # # Sets default values for the controlling terminal and redirects # stdin/stdout/stderr to it if necessary # CMD=mcsel usage() { echo "usage: $CMD [-k]" >&2 exit 1 } while getopts ":k" c do case "$c" in k) k_flag=1;; :|'?') usage;; esac done tty -s; isatty=$? if [ $isatty -ne 0 ]; then oldtty=$(stty -g /dev/null 2>&1 # Set application cursor keys mode [ -n "$k_flag" ] && echo -n "[?1h" >/dev/tty fi .