寻找一个GUI应用程序来输入linux命令

mil*_*epa 2 python linux user-interface tcl command-line-interface

我正在寻找一个GUI控制台,我可以在一个条目小部件中输入linux命令,结果将在文本区域小部件中输出.有这样的软件吗?像这样的东西:

在此输入图像描述

一个控制台程序,如gnome-terminal或xterm,屏幕随每个新命令一直滚动,当结果有几十行时我发现这很烦人.

我想同时可视化命令和结果,就像浏览器在地址栏中输入网址并获得网站一样.

谢谢.

Joh*_*uhn 8

好吧,这样的事情很容易在Tcl中实现.

package require Tk 8.5
grid [ttk::entry .input -textvariable input] -sticky nesw
grid [text .text] -sticky nesw
grid rowconfigure . .text -weight 1
grid columnconfigure . .text -weight 1
bind .input <Return> execute
bind .input <Up> {histwalk -1}
bind .input <Down> {histwalk 1}

proc execute {} {
    history add $::input
    set ::eventcnt 0
    .text delete 1.0 end
    catch {exec /bin/bash -c $::input} res
    .text insert 1.0 $res
    .input selection range 0 end
}

set eventcnt 0
proc histwalk i {
   incr ::eventcnt $i
   set ::input [history event $::eventcnt]
   .input selection range 0 end
}
Run Code Online (Sandbox Code Playgroud)

  • tclreadline对于这个来说将是错误的工具,但也许有点hetroy东西有帮助. (2认同)
  • 在`incr :: eventcnt $ i`之后添加行`if {$ :: eventcnt == [history nextid]} {set :: eventcnt 1}`.否则会抛出错误. (2认同)