fb:porticula NoPaste
milkrun (schon besser)
Uploader: | MilkFreeze |
Datum/Zeit: | 13.06.2011 20:48:32 |
#include "list.bi"
makelist(string,string)
dim path as string
dim path_list as string_list
dim cmd as string
dim cmd_list as string_list
dim x as integer
dim i as integer
dim key as string
dim hints as string_list
dim hit as integer
dim selection as integer = 1
open pipe "echo $PATH" for input as #1
input #1, path
close #1
while (path <> "" and instr(path, ":") > 0)
path_list.append(left(path, instr(path, ":") -1) + "/")
path = mid(path, instr(path, ":") +1)
wend
for i as integer = 1 to path_list.count()
open pipe "ls "& path_list.item(i) &" --color=never" for input as #2
while not eof(2)
input #2, cmd
if cmd <> "" then
cmd_list.append(cmd)
end if
wend
close #2
next
do
sleep
cls
key = inkey
select case asc(key)
case 8
cmd = left(cmd, len(cmd) -1)
case 9
if hints.item(selection) <> "" then
cmd = hints.item(selection)
end if
case 13
if hints.item(selection) = "" then
shell "echo ""starting " & cmd
shell "nohup " & cmd & " >/dev/null &"
else
shell "echo ""starting " & hints.item(selection) &""""
shell "nohup " & hints.item(selection) & " >/dev/null &"
end if
end 0
case 255
if asc( key,2) = 75 then
if selection > 1 then selection -= 1
elseif asc(key,2) = 77 then
if selection < hints.count then selection += 1
end if
case else
cmd += key
end select
hit = 0
i = 0
hints.destroy()
x = 0
while (x < 6 and i < cmd_list.count)
i += 1
if left(cmd_list.item(i), len(cmd)) = cmd then
if hit = 0 then hit = i
hints.append( cmd_list.item(i) )
x += 1
end if
wend
locate 1,1
? cmd
locate 2,1
for i = 1 to hints.count
if i = selection then
? ">" & hints.item(i) & "< ";
else
? hints.item(i) &" ";
end if
next
if (hints.count() < selection) then
selection = hints.count
end if
loop