handy

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

o (2740B)


      1 #! /bin/sh
      2 
      3 while [ $# -gt 0 ] ; do
      4 	if [ -e "$1" ]; then
      5 		mime_type=$(file -L -b --mime-type "$1")
      6 		fdb -i "$XDG_DATA_HOME"/open.z -a "$(realpath "$1")"
      7 		case $mime_type in
      8 			inode/x-empty)
      9 				e "$1"
     10 				;;
     11 			video/*|application/vnd.rn-realmedia)
     12 				vp "$1"
     13 				;;
     14 			audio/*)
     15 				ap "$1"
     16 				;;
     17 			image/vnd.djvu)
     18 				open -a djview "$1"
     19 				;;
     20 			image/x-canon-cr2)
     21 				dcraw -T -w "$1"
     22 				;;
     23 			image/svg+xml|application/x-shockwave-flash)
     24 				wb "$1"
     25 				;;
     26 			image/x-xcf)
     27 				open -a Gimp "$1"
     28 				;;
     29 			image/*)
     30 				iv "$1"
     31 				;;
     32 			application/x-lha)
     33 				lha x "$1"
     34 				;;
     35 			application/postscript|application/pdf)
     36 				dr "$1"
     37 				;;
     38 			application/zip)
     39 				unzip -d "${1%.*}" "$1"
     40 				;;
     41 			application/x-tar)
     42 				tar xvf "$1"
     43 				;;
     44 			application/x-rar)
     45 				unrar -ad x "$1"
     46 				;;
     47 			application/vnd.ms-opentype|application/x-font-ttf|application/vnd.font-fontforge-sfd)
     48 				fontforge "$1"
     49 				;;
     50 			text/html)
     51 				wb "$1"
     52 				;;
     53 			text/troff)
     54 				man "$1"
     55 				;;
     56 			*)
     57 				case "$1" in
     58 					*.tar.gz|*.tgz)
     59 						tar xvzf "$1"
     60 						;;
     61 					*.tar.xz)
     62 						tar xvJf "$1"
     63 						;;
     64 					*.tar.bz2|*.tbz2|*.tbz)
     65 						tar xvjf "$1"
     66 						;;
     67 					*.bz2)
     68 						bunzip2 "$1"
     69 						;;
     70 					*.tar)
     71 						tar xvf "$1"
     72 						;;
     73 					*.gz)
     74 						gunzip "$1"
     75 						;;
     76 					*.ace)
     77 						unace x "$1"
     78 						;;
     79 					*.7z)
     80 						7z x "$1"
     81 						;;
     82 					*.chm|*.epub)
     83 						open "$1"
     84 						;;
     85 					*.nzb)
     86 						nzbget -A "$1"
     87 						;;
     88 					*.nfo)
     89 						e "$1"
     90 						;;
     91 					*.pcf|*.bdf|*.pfb)
     92 						fontforge "$1"
     93 						;;
     94 					*.svg)
     95 						wb "$1"
     96 						;;
     97 					*.pps|*.PPS|*.ppt|*.PPT)
     98 						ppsei "$1"
     99 						;;
    100 					*.abw)
    101 						abiword "$1"
    102 						;;
    103 					*.rtf|*.doc)
    104 						catdoc -w -s cp1252 "$1"
    105 						;;
    106 					*.xls)
    107 						xls2csv -s cp1252 "$1"
    108 						;;
    109 					*.xpm)
    110 						iv "$1"
    111 						;;
    112 					*.mp3|*.m3u|*.ogg|*.mpc)
    113 						ap "$1"
    114 						;;
    115 					*.mp4|*.avi|*.mpg|*.mpeg|*.mkv|*.webm|*.ogv|*.f4v|*.m2ts|*.ts)
    116 						vp "$1"
    117 						;;
    118 					*.webarchive)
    119 						tmp_xml=$(mktemp /tmp/xml.XXXX)
    120 						tmp_html=$(mktemp /tmp/html.XXXX)
    121 						plutil -i "$1" -o "$tmp_xml"
    122 						webarchive_decodemain "$tmp_xml" > "$tmp_html"
    123 						wb "$tmp_html"
    124 						rm "$tmp_xml"
    125 						;;
    126 					*.blend)
    127 						blender "$1"
    128 						;;
    129 					*.emulecollection)
    130 						amule-emc "$1"
    131 						;;
    132 					*.sparseimage)
    133 						open "$1"
    134 						;;
    135 					*)
    136 						mime_encoding=$(file -L -b --mime-encoding "$1")
    137 						case $mime_encoding in
    138 							*binary)
    139 								xxd -l 128 "$1"
    140 								;;
    141 							*)
    142 								e "$1"
    143 								;;
    144 						esac
    145 						;;
    146 				esac
    147 				;;
    148 		esac
    149 	else
    150 		case "$1" in
    151 			*://*)
    152 				wb "$1"
    153 				;;
    154 			*:*)
    155 				open "$1"
    156 				;;
    157 			*@*.*)
    158 				mutt "$1"
    159 				;;
    160 			*)
    161 				echo "file not found: '$1'" >&2
    162 				exit 1
    163 				;;
    164 		esac
    165 	fi
    166 	shift
    167 done