diff --git a/etc/conf/vimrc b/etc/conf/vimrc index efd9ca7d..3d349421 100644 --- a/etc/conf/vimrc +++ b/etc/conf/vimrc @@ -20,7 +20,7 @@ Plug 'tpope/vim-fugitive' Plug 'gcmt/taboo.vim' set sessionoptions+=tabpages,globals -Plug 'fatih/vim-go' +let g:go_highlight_functions=1 Plug 'fatih/vim-go' let g:go_version_warning=0 Plug 'chr4/nginx.vim' @@ -165,3 +165,5 @@ cnoremap RR :source ~/.vimrc colorscheme torte highlight Comment cterm=reverse ctermfg=yellow "}}} +" +nnoremap :NERDTreeToggle diff --git a/src/contexts/web/web.go b/src/contexts/web/web.go index f07472c8..15ad45b7 100644 --- a/src/contexts/web/web.go +++ b/src/contexts/web/web.go @@ -518,7 +518,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", Form: map[string]int{ "which": 1, "method": 1, "args": 1, "headers": 2, "content_type": 1, "content_data": 1, "body": 1, "file": 2, - "parse": 1, "temp": -1, "temp_expire": 1, "save": 1, + "parse": 1, "temp": -1, "temp_expire": 1, "save": 1, "saves": 1, }, Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { // 查看配置 if len(arg) == 0 { @@ -726,6 +726,15 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", m.Echo(string(buf)) } } + if m.Options("saves") { + f, p, e := kit.Create(m.Option("saves")) + m.Assert(e) + defer f.Close() + for _, v := range m.Meta["result"] { + f.WriteString(v) + } + m.Set("result").Echo(p) + } return }}, diff --git a/src/examples/chat/chat.go b/src/examples/chat/chat.go index 06f29274..0e3184e8 100644 --- a/src/examples/chat/chat.go +++ b/src/examples/chat/chat.go @@ -480,7 +480,7 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心", case "file": m.Cmdy("/download/" + h) case "wiki": - m.Cmdy("web.wiki.note", kit.Format(value["code"])) + m.Cmdy("ssh._route", value["dream"], "web.wiki.note", value["code"]) } m.Grow("share", nil, map[string]interface{}{ "time": m.Time(), @@ -496,7 +496,7 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心", }) return }}, - "share": &ctx.Command{Name: "share type code", Help: "共享链接", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { + "share": &ctx.Command{Name: "share type code", Help: "共享链接", Hand: func(m *ctx.Message, c *ctx.Context, cmd string, arg ...string) (e error) { if len(arg) == 0 { fields := strings.Split(m.Conf("share", "meta.fields"), " ") m.Grows("share", nil, func(meta map[string]interface{}, index int, value map[string]interface{}) { @@ -505,14 +505,15 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心", m.Table() return } - h := kit.Hashs("uniq") - m.Confv("share", []string{"hash", h}, map[string]interface{}{ - "from": m.Option("username"), - "time": m.Time(), - "type": arg[0], - "code": arg[1], + h := kit.ShortKey(m.Confm(cmd, "hash"), 6) + m.Confv(cmd, []string{"hash", h}, map[string]interface{}{ + "from": m.Option("username"), + "time": m.Time(), + "type": arg[0], + "code": arg[1], + "dream": kit.Select("", arg, 2), }) - m.Echo(h) + m.Echo("%s/chat/share/%s", m.Cmdx(".spide", "self", "client", "url"), h) return }}, }, diff --git a/src/examples/code/code.go b/src/examples/code/code.go index 57f64a14..4783c7b6 100644 --- a/src/examples/code/code.go +++ b/src/examples/code/code.go @@ -58,6 +58,15 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", "template": map[string]interface{}{"shy": Dockfile}, "output": "etc/Dockerfile", }}, + "tmux": {Name: "tmux", Help: "终端", Value: map[string]interface{}{ + "favor": map[string]interface{}{ + "index": []interface{}{ + "ctx_dev ctx_share", + "curl -s $ctx_dev/publish/auto.sh >auto.sh", + "source auto.sh", + }, + }, + }}, "git": {Name: "git", Help: "记录", Value: map[string]interface{}{ "alias": map[string]interface{}{"s": "status", "b": "branch"}, }}, @@ -159,6 +168,9 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", }, }, }, + "session": map[string]interface{}{"meta": map[string]interface{}{ + "fields": "river dream favor story stage order expire", + }}, "share": map[string]interface{}{"meta": map[string]interface{}{ "fields": "river dream favor story stage order expire", }}, @@ -186,11 +198,16 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", m.Cmd(git, strings.Split(value, " ")) }) + // 创建文档 + m.Cmd("cli.system", "mkdir", "-p", path.Join(home, "wiki")) + m.Cmd("cli.system", "touch", path.Join(home, "wiki/miss.md")) + // 创建终端 share := m.Cmdx(cmd, "share", topic) m.Cmd(tmux, "set-environment", "-g", "ctx_share", share) m.Cmd(tmux, "new-session", "-ds", arg[1], "cmd_dir", home, "cmd_env", "TMUX", "") m.Cmd(tmux, "set-environment", "-t", arg[1], "ctx_share", share) + m.Cmd(tmux, "set-environment", "-t", arg[1], "ctx_dev", os.Getenv("ctx_self")) m.Confm(cmd, []string{"layout", m.Conf(cmd, []string{"topic", topic, "layout", "0"})}, func(index int, value string) { value = strings.Replace(value, "$dream", arg[1], -1) m.Cmd(tmux, strings.Split(value, " "), "cmd_dir", home) @@ -199,6 +216,7 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", value = strings.Replace(value, "$dream", arg[1], -1) m.Cmd(tmux, strings.Split(value, " "), "cmd_dir", home) }) + m.Conf("dream", "session."+m.Option("dream")+"."+"share", share) m.Echo(share) case "share": @@ -658,11 +676,29 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", } switch arg[3] { - // 操作缓存 - case "buffer": - if len(arg) > 5 { - m.Cmdy(prefix, "set-buffer", "-b", arg[4], arg[5]) + case "favor": + env := m.Cmdx(prefix, "show-environment", "-g") + m.Cmdx(prefix, "show-environment") + for _, l := range strings.Split(env, "\n") { + if strings.HasPrefix(l, "ctx_") { + v := strings.SplitN(l, "=", 2) + m.Option(v[0], v[1]) + } } + + m.Confm("tmux", "favor."+kit.Select("index", arg, 4), func(index int, value string) { + if index == 0 { + keys := strings.Split(value, " ") + value = "export" + for _, k := range keys { + value += " " + k + "=" + m.Option(k) + } + + } + m.Cmdy(prefix, "send-keys", "-t", target, value, "Enter") + }) + + case "buffer": + // 操作缓存 if len(arg) > 4 { m.Cmdy(prefix, "show-buffer", "-b", arg[4]) return @@ -676,8 +712,8 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", } } return - // 面板列表 case "pane": + // 面板列表 m.Cmdy(prefix, "list-panes", "-a", "cmd_parse", "cut", " ", "8", "pane_name size some lines bytes haha pane_id tag") m.Meta["append"] = []string{"pane_id", "pane_name", "size", "lines", "bytes", "tag"} m.Table(func(index int, value map[string]string) { @@ -689,13 +725,15 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", m.Sort("pane_name") m.Table() return - // 运行命令 case "run": + // 运行命令 arg = arg[1:] fallthrough default: - m.Cmdy(prefix, "send-keys", "-t", target, strings.Join(arg[3:], " "), "Enter") - time.Sleep(1 * time.Second) + if len(arg) > 3 { + m.Cmdy(prefix, "send-keys", "-t", target, strings.Join(arg[3:], " "), "Enter") + time.Sleep(1 * time.Second) + } } } diff --git a/src/plugin/docker/index.shy b/src/plugin/docker/index.shy index 75118c09..bb2129a2 100644 --- a/src/plugin/docker/index.shy +++ b/src/plugin/docker/index.shy @@ -23,15 +23,22 @@ kit clip "粘贴板" private "web.code.tmux" "" "" "" "buffer" \ button "返回" cb Last kit tmux "终端" private "web.code.tmux" \ - text "context" name session imports plugin_session action auto \ + text "" name session imports plugin_session action auto \ text "" name window imports plugin_window action auto \ text "" name pane imports plugin_pane view char action auto \ - text "" name cmd \ exports session session "" window window "" pane pane "" \ - ueature detail "复制" "下载" "修改" \ button "查看" action auto \ button "返回" cb Last +kit tmuxs "终端" private "web.code.tmux" \ + text "" name session imports plugin_session \ + text "" name window imports plugin_window \ + text "" name pane imports plugin_pane view char \ + select "" name cmd values "favor buffer pane run"\ + text "" name arg \ + ueature detail "复制" "下载" "修改" \ + button "执行" + kit image "镜像" private "web.code.docker" "image" \ text "" name pos imports plugin_REPOSITORY \ text "" name tag imports plugin_TAG \ diff --git a/src/plugin/story/index.shy b/src/plugin/story/index.shy index 7d97ceb6..5c84343c 100644 --- a/src/plugin/story/index.shy +++ b/src/plugin/story/index.shy @@ -1,3 +1,9 @@ +kit share "共享" public "web.chat.share" \ + select "" name type values "wiki file" \ + text "miss.md" name story imports plugin_story view long \ + text "" name dream imports plugin_you \ + button "共享" + kit note "记事本" public "ssh._route" _ "web.wiki.note" \ text "" name dream imports plugin_you action auto \ text "miss.md" name story imports plugin_story view long action auto \