#!/usr/bin/env wish-fb # # usage: xls [dir] # # start off a "d ls -lg" of the current directory, with some # extra buttons and such for further navigation if [catch { global argv if [string length $argv] {cd $argv} proc which {f} { global env foreach x [split $env(PATH) :] { if [file exists "$x/$f"] {return "$x/$f"} } return "" } set argv [list -t [exec pwd] /dev/null] source [which xd] proc f {args} { global file if [llength $args]==0 { set s [selection get] catch {regexp {^(.*) -> .*$} $s s s} catch {regexp {^.* (.*)$} $s s s} set s } elseif [llength $args]==1 { set file([lindex $args 0]) } else { set file([lindex $args 0]) [lindex $args 1] }} proc set-f {pos} { catch {f p [f]} .text mark set anchor $pos .text mark set insert $pos .text tag remove sel 1.0 end .text tag add sel "$pos linestart" "$pos lineend"} proc browse {args} { if [string length $args] {set-f $args} set done 0 foreach x { {{^d} {exec xls [f] &}} {{\.[Zz]( |$)} {exec d zcat [f] &}} {{\.gz( |$)} {exec d zcat [f] &}} {{\.gif( |$)} {exec xv [f] &}} {{\.GIF( |$)} {exec xv [f] &}} {{\.xbm( |$)} {exec xv [f] &}} {{\.mpg( |$)} {exec mpeg_play -dither 2x2 [f] &}} {{\.mpeg( |$)} {exec mpeg_play -dither 2x2 [f] &}} {{\.ps( |$)} {exec ghostview [f] &}} {{^l} {if [file isdirectory [f]] { exec xls [f] &} {exec xd [f] &}}} {{^} {exec xd [f] &}} } { if !$done&&[regexp [lindex $x 0] [selection get]] { eval [lindex $x 1] set done 1 } } } pack [button .panel.ls -text reread -command { set saveposition [.text index @1,1] .text configure -state normal .text delete 1.0 end .text insert 1.0 [exec ls -alg .] .text configure -state disabled .text yview $saveposition}] -side right pack [button .panel.rm -text remove -command { exec rm -rf [f] & }] -side right pack [button .panel.xe -text edit -command { exec xe [f] & }] -side right pack [button .panel.browse -text browse -command browse] -side right bind .text {browse @%x,%y} bind .text {set-f @%x,%y} .panel.ls invoke } err] { tkerror $err exit 2 }