mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-25 16:58:06 +08:00
add login.vim
This commit is contained in:
parent
4b02000c3d
commit
be8170efe1
@ -8,6 +8,7 @@ ctx_url=$ctx_dev"/code/zsh"
|
||||
ctx_head=${ctx_head:="Content-Type: application/json"}
|
||||
ctx_sync=${ctx_sync:=""}
|
||||
ctx_sid=${ctx_sid:=""}
|
||||
|
||||
ctx_welcome=${ctx_welcome:="^_^ Welcome to Context world ^_^"}
|
||||
ctx_goodbye=${ctx_goodbye:="^_^ Welcome to Context world ^_^"}
|
||||
|
||||
@ -24,9 +25,19 @@ ShyJSON() {
|
||||
echo -n "}"
|
||||
}
|
||||
ShyPost() {
|
||||
local data=`ShyJSON "$@" SHELL "${SHELL}" pwd "${PWD}" sid "${ctx_sid}"`
|
||||
if [ "$SHELL" = "/bin/zsh" ]; then
|
||||
ShyJSON "$@" SHELL "${SHELL}" pwd "${PWD}" sid "${ctx_sid}"|read data
|
||||
else
|
||||
local data=`ShyJSON "$@" SHELL "${SHELL}" pwd "${PWD}" sid "${ctx_sid}"`
|
||||
fi
|
||||
curl -s "${ctx_url}" -H "${ctx_head}" -d "${data}"
|
||||
}
|
||||
ShyUpload() {
|
||||
curl "${ctx_dev}/upload" -F "upload=@$1"
|
||||
}
|
||||
ShyDownload() {
|
||||
curl "${ctx_dev}/download/$1"
|
||||
}
|
||||
ShyWord() {
|
||||
echo "$*"|sed -e 's/\ /%20/g' -e 's/\n/\\n/g'
|
||||
}
|
||||
@ -38,7 +49,7 @@ ShyForm() {
|
||||
}
|
||||
ShyGet() {
|
||||
local data=`ShyForm "$@" SHELL "${SHELL}" pwd "${PWD}" sid "${ctx_sid}"`
|
||||
curl -s "${ctx_url}?${data}"
|
||||
wget -q "${ctx_url}?${data}"
|
||||
}
|
||||
Shy() {
|
||||
local ctx_res=`ShyPost cmd "$1" arg "$2"`
|
||||
@ -50,9 +61,20 @@ Shy() {
|
||||
|
||||
ShySync() {
|
||||
case "$1" in
|
||||
"historys")
|
||||
ctx_end=`history|tail -n1|awk '{print $1}'`
|
||||
ctx_tail=`expr $ctx_end - $ctx_begin`
|
||||
echo $ctx_begin - $ctx_end $ctx_tail
|
||||
history|tail -n $ctx_tail |while read line; do
|
||||
line=`ShyLine $line`
|
||||
ShyPost arg "$line" cmd historys FORMAT "$HISTTIMEFORMAT"
|
||||
echo $line
|
||||
done
|
||||
ctx_begin=$ctx_end
|
||||
;;
|
||||
"history") tail -n0 -f $HISTFILE | while true; do read line
|
||||
line=`ShyLine $line`
|
||||
Shy history "$line"
|
||||
ShyPost arg "$line" cmd history FORMAT "$HISTTIMEFORMAT"
|
||||
echo $line
|
||||
done;;
|
||||
"input")
|
||||
@ -67,9 +89,16 @@ ShyHistory() {
|
||||
ShySync history &>/dev/null &
|
||||
ctx_sync=$!
|
||||
;;
|
||||
*) bind -x '"\C-gl":ShySync input'
|
||||
*)
|
||||
ctx_begin=`history|tail -n1|awk '{print $1}'`
|
||||
echo "begin: $ctx_begin"
|
||||
bind -x '"\C-gl":ShySync input'
|
||||
;;
|
||||
esac
|
||||
}
|
||||
ShyRecord() {
|
||||
script $1
|
||||
}
|
||||
ShyLogout() {
|
||||
echo ${ctx_goodbye}
|
||||
Shy logout
|
||||
@ -80,7 +109,15 @@ ShyLogin() {
|
||||
echo "url: ${ctx_url}"
|
||||
echo "sid: ${ctx_sid:0:6}"
|
||||
echo "pid: $$"
|
||||
echo "begin: ${ctx_begin}"
|
||||
}
|
||||
ShyInit() {
|
||||
case "$SHELL" in
|
||||
"/bin/zsh");;
|
||||
*) PS1="\!-\t[\u@\h]\W\$ ";;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
ShyLogin && trap ShyLogout EXIT
|
||||
ShyInit && ShyLogin && trap ShyLogout EXIT
|
||||
|
||||
|
@ -1,14 +1,21 @@
|
||||
|
||||
let ctx_dev = (len($ctx_dev) > 1? $ctx_dev: "http://127.0.0.1:9095") . "/code/vim"
|
||||
let ctx_url = (len($ctx_dev) > 1? $ctx_dev: "http://127.0.0.1:9095") . "/code/vim"
|
||||
let ctx_head = "Content-Type: application/json"
|
||||
let ctx_sid = ""
|
||||
|
||||
fun! ShyPost(arg)
|
||||
return system("curl -s '" . g:ctx_dev . "' -H 'Content-Type: application/json' -d '" . json_encode(a:arg) . "' 2>/dev/null")
|
||||
let a:arg["pwd"] = getcwd()
|
||||
let a:arg["sid"] = g:ctx_sid
|
||||
return system("curl -s '" . g:ctx_url . "' -H '" . g:ctx_head . "' -d '" . json_encode(a:arg) . "' 2>/dev/null")
|
||||
endfun
|
||||
|
||||
fun! Shy(action, target)
|
||||
let arg = {"arg": a:target, "cmd": a:action, "pwd": getcwd(), "pid": getpid(), "pane": $TMUX_PANE, "hostname": hostname(), "username": $USER}
|
||||
if g:ctx_sid == ""
|
||||
call ShyLogin()
|
||||
endif
|
||||
let arg = {"arg": a:target, "cmd": a:action}
|
||||
if a:action == "sync"
|
||||
let cmd = {"tags": "tags", "bufs": "buffers", "regs": "registers", "marks": "marks"}
|
||||
let cmd = {"tags": "tags", "fixs": "clist", "bufs": "buffers", "regs": "registers", "marks": "marks"}
|
||||
let arg[a:target] = execute(cmd[a:target])
|
||||
endif
|
||||
|
||||
@ -19,12 +26,23 @@ fun! Shy(action, target)
|
||||
endif
|
||||
endfun
|
||||
|
||||
fun! ShyLogout()
|
||||
call Shy("logout", "")
|
||||
endfun
|
||||
fun! ShyLogin()
|
||||
let arg = {"cmd": "login", "pid": getpid(), "pane": $TMUX_PANE, "hostname": hostname(), "username": $USER}
|
||||
let g:ctx_sid = ShyPost(arg)
|
||||
endfun
|
||||
autocmd VimEnter * call ShyLogin()
|
||||
autocmd VimLeave * call ShyLogout()
|
||||
|
||||
autocmd BufReadPost * call Shy("read", expand("<afile>"))
|
||||
autocmd BufWritePre * call Shy("write", expand("<afile>"))
|
||||
autocmd BufUnload * call Shy("close", expand("<afile>"))
|
||||
|
||||
autocmd BufWritePost * call Shy("sync", "bufs")
|
||||
autocmd BufWritePost * call Shy("sync", "tags")
|
||||
autocmd BufWritePost * call Shy("sync", "fixs")
|
||||
autocmd BufWritePost * call Shy("sync", "bufs")
|
||||
autocmd BufWritePost * call Shy("sync", "regs")
|
||||
|
||||
" autocmd BufWinEnter * call Shy("enter", expand("<afile>"))
|
||||
|
@ -11,7 +11,7 @@ set -g history-limit 1000
|
||||
set -g mode-keys vi
|
||||
|
||||
set -gw other-pane-width 60
|
||||
set -gw other-pane-height 12
|
||||
set -gw other-pane-height 15
|
||||
|
||||
set -g set-titles on
|
||||
set -g set-titles-string "#(whoami)@#h/#{session_name}:#{window_name}.#{pane_index} #{pane_current_command}"
|
||||
@ -73,8 +73,8 @@ bind \; paste-buffer
|
||||
|
||||
bind r choose-buffer
|
||||
bind a paste-buffer
|
||||
bind -t vi-copy s begin-selection
|
||||
bind -t vi-copy a copy-selection
|
||||
bind -t vi-copy c copy-selection
|
||||
bind -t vi-copy Space begin-selection
|
||||
|
||||
# }}}
|
||||
# 命令管理{{{
|
||||
|
@ -24,3 +24,4 @@
|
||||
# 终端配置
|
||||
~cli
|
||||
|
||||
~code
|
||||
|
@ -887,8 +887,11 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
m.Cmdy("web.code.git", "", "sum", arg[1:])
|
||||
|
||||
case "trends":
|
||||
m.Cmdy("web.code.git", "", "sum", "total", arg[1:])
|
||||
// 提交记录
|
||||
if len(arg) == 1 {
|
||||
arg = append(arg, "2017-11-01")
|
||||
}
|
||||
m.Cmdy("web.code.git", "", "sum", "total", arg[1:])
|
||||
|
||||
case "submit":
|
||||
// 提交代码
|
||||
|
@ -257,7 +257,7 @@ func (m *Message) Push(key interface{}, arg ...interface{}) *Message {
|
||||
m.Add("append", "key", key)
|
||||
key = "value"
|
||||
}
|
||||
m.Add("append", key, kit.Format(kit.Chain(arg[0], key)))
|
||||
m.Add("append", key, kit.Select(" ", kit.Format(kit.Chain(arg[0], key))))
|
||||
}
|
||||
}
|
||||
return m
|
||||
@ -362,8 +362,9 @@ func (m *Message) Split(str string, arg ...string) *Message {
|
||||
}
|
||||
continue
|
||||
}
|
||||
for i, v := range kit.Split(l, c, len(heads)) {
|
||||
m.Add("append", heads[i], v)
|
||||
ls := kit.Split(l, c, len(heads))
|
||||
for i, v := range heads {
|
||||
m.Add("append", v, kit.Select("", ls, i))
|
||||
}
|
||||
}
|
||||
m.Table()
|
||||
|
@ -996,12 +996,18 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
||||
m.Cmd("nfs.copy", path.Join(m.Conf("web.upload", "path"), kind, code), p)
|
||||
}
|
||||
}
|
||||
|
||||
m.Append("size", kit.FmtSize(n))
|
||||
m.Append("link", fmt.Sprintf(`<a href="/download/%s" target="_blank">%s</a>`, code, h.Filename))
|
||||
m.Append("type", kind)
|
||||
m.Append("hash", name)
|
||||
m.Table()
|
||||
if !strings.HasPrefix(m.Option("agent"), "curl") {
|
||||
m.Append("size", kit.FmtSize(n))
|
||||
m.Append("link", fmt.Sprintf(`<a href="/download/%s" target="_blank">%s</a>`, code, h.Filename))
|
||||
m.Append("type", kind)
|
||||
m.Append("hash", name)
|
||||
m.Table()
|
||||
} else {
|
||||
m.Echo("code: %s\n", code)
|
||||
m.Echo("hash: %s\n", name)
|
||||
m.Echo("type: %s\n", kind)
|
||||
m.Echo("size: %s\n", kit.FmtSize(n))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,11 +46,11 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
"shy": Dockfile,
|
||||
}},
|
||||
"git": {Name: "git", Help: "记录", Value: map[string]interface{}{
|
||||
"alias": map[string]interface{}{"s": "status", "b": "branch"},
|
||||
"config": []interface{}{map[string]interface{}{"conf": "merge.tool", "value": "vimdiff"}},
|
||||
"alias": map[string]interface{}{"s": "status", "b": "branch"},
|
||||
}},
|
||||
"vim": {Name: "vim", Help: "记录", Value: map[string]interface{}{
|
||||
"opens": map[string]interface{}{},
|
||||
"editor": map[string]interface{}{},
|
||||
"opens": map[string]interface{}{},
|
||||
}},
|
||||
"zsh": {Name: "vim", Help: "记录", Value: map[string]interface{}{
|
||||
"terminal": map[string]interface{}{},
|
||||
@ -81,6 +81,17 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
m.Conf("zsh", []string{"terminal", name, "time"}, m.Time())
|
||||
return
|
||||
|
||||
case "historys":
|
||||
name := m.Option("sid")
|
||||
vs := strings.SplitN(strings.TrimSpace(m.Option("arg")), " ", 2)
|
||||
m.Conf("zsh", []string{"history", name, "-2"}, map[string]interface{}{
|
||||
"sid": name,
|
||||
"time": m.Time(),
|
||||
"index": vs[0],
|
||||
"cmd": kit.Select("", vs, 1),
|
||||
"pwd": m.Option("pwd"),
|
||||
})
|
||||
|
||||
case "history":
|
||||
switch path.Base(m.Option("SHELL")) {
|
||||
case "zsh":
|
||||
@ -88,7 +99,7 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
}
|
||||
|
||||
name := m.Option("sid")
|
||||
m.Conf("zsh", []string{"history", name, "-1"}, map[string]interface{}{
|
||||
m.Conf("zsh", []string{"history", name, "-2"}, map[string]interface{}{
|
||||
"sid": name,
|
||||
"time": m.Time(),
|
||||
"cmd": m.Option("arg"),
|
||||
@ -111,9 +122,19 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
m.Sort("time", "time_r").Table()
|
||||
case "history":
|
||||
m.Confm("zsh", "history", func(key string, index int, value map[string]interface{}) {
|
||||
m.Push([]string{"time", "sid", "cmd", "pwd"}, value)
|
||||
if len(arg) > 1 && !strings.HasPrefix(key, arg[1]) {
|
||||
return
|
||||
}
|
||||
if sid := kit.Format(value["sid"]); len(sid) > 6 {
|
||||
value["sid"] = sid[:6]
|
||||
}
|
||||
m.Push([]string{"time", "sid", "index", "cmd", "pwd"}, value)
|
||||
})
|
||||
m.Sort("time", "time_r").Table()
|
||||
if len(arg) > 1 {
|
||||
m.Sort("index", "int_r").Table()
|
||||
} else {
|
||||
m.Sort("time", "time_r").Table()
|
||||
}
|
||||
case "prune":
|
||||
ps := []string{}
|
||||
m.Confm("zsh", []string{"terminal"}, func(key string, value map[string]interface{}) {
|
||||
@ -122,7 +143,7 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
}
|
||||
})
|
||||
for _, v := range ps {
|
||||
m.Log("info", "prune %v %v", v, kit.Formats(m.Conf("zsh", []string{"terminal", v})))
|
||||
m.Log("info", "prune zsh %v %v", v, kit.Formats(m.Conf("zsh", []string{"terminal", v})))
|
||||
m.Confv("zsh", []string{"terminal", v}, "")
|
||||
}
|
||||
|
||||
@ -544,24 +565,49 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
}},
|
||||
"vim": {Name: "vim", Help: "编辑器", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
switch arg[0] {
|
||||
case "opens":
|
||||
m.Confm("vim", "opens", func(key string, value map[string]interface{}) {
|
||||
m.Push([]string{"time", "action", "file", "pid", "pane", "hostname", "username"}, value)
|
||||
case "editor":
|
||||
m.Confm("vim", "editor", func(key string, value map[string]interface{}) {
|
||||
m.Push([]string{"time", "sid", "status", "pwd", "pid", "pane", "hostname", "username"}, value)
|
||||
})
|
||||
m.Sort("time", "time_r").Table()
|
||||
case "opens":
|
||||
m.Confm("vim", "opens", func(key string, value map[string]interface{}) {
|
||||
value["sid"] = kit.Format(value["sid"])[:6]
|
||||
m.Push([]string{"time", "sid", "action", "file"}, value)
|
||||
})
|
||||
m.Sort("time", "time_r").Table()
|
||||
case "prune":
|
||||
ps := []string{}
|
||||
m.Confm("vim", []string{"editor"}, func(key string, value map[string]interface{}) {
|
||||
if kit.Format(value["status"]) == "logout" {
|
||||
ps = append(ps, key)
|
||||
}
|
||||
})
|
||||
for _, v := range ps {
|
||||
for _, k := range []string{"editor", "tag", "fix", "buffer", "register"} {
|
||||
m.Log("info", "prune vim %v %v %v", k, v, kit.Formats(m.Conf("vim", []string{k, v})))
|
||||
m.Confv("vim", []string{k, v}, "")
|
||||
}
|
||||
}
|
||||
|
||||
case "tags":
|
||||
m.Confm("vim", "tag", func(key string, index int, value map[string]interface{}) {
|
||||
m.Push("sid", key[:6]).Push([]string{"tag", "line", "file"}, value)
|
||||
})
|
||||
m.Table()
|
||||
case "fixs":
|
||||
m.Confm("vim", "fix", func(key string, index int, value map[string]interface{}) {
|
||||
m.Push("sid", key[:6]).Push([]string{"id", "file", "line", "text"}, value)
|
||||
})
|
||||
m.Table()
|
||||
case "bufs":
|
||||
m.Confm("vim", "buffer", func(key string, index int, value map[string]interface{}) {
|
||||
m.Push([]string{"id", "tag", "name", "line", "hostname", "username"}, value)
|
||||
m.Push("sid", key[:6]).Push([]string{"id", "tag", "name", "line"}, value)
|
||||
})
|
||||
m.Table()
|
||||
case "regs":
|
||||
m.Confm("vim", "register", func(key string, index int, value map[string]interface{}) {
|
||||
m.Push([]string{"name", "text", "hostname", "username"}, value)
|
||||
})
|
||||
m.Table()
|
||||
case "tags":
|
||||
m.Confm("vim", "tag", func(key string, index int, value map[string]interface{}) {
|
||||
m.Push([]string{"tag", "line", "file", "hostname", "username"}, value)
|
||||
m.Push("sid", key[:6]).Push([]string{"name", "text"}, value)
|
||||
})
|
||||
m.Table()
|
||||
}
|
||||
@ -570,64 +616,83 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
"/vim": {Name: "/vim", Help: "编辑器", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
if !m.Has("res") {
|
||||
switch m.Option("cmd") {
|
||||
case "read", "enter", "leave", "write", "close", "unload":
|
||||
case "login":
|
||||
name := kit.Hashs(m.Option("pid"), m.Option("hostname"), m.Option("username"))
|
||||
m.Conf("vim", []string{"editor", name}, map[string]interface{}{
|
||||
"sid": name,
|
||||
"status": "login",
|
||||
"time": m.Time(),
|
||||
"pwd": m.Option("pwd"),
|
||||
"pid": m.Option("pid"),
|
||||
"pane": m.Option("pane"),
|
||||
"hostname": m.Option("hostname"),
|
||||
"username": m.Option("username"),
|
||||
})
|
||||
m.Echo(name)
|
||||
return
|
||||
case "logout":
|
||||
name := m.Option("sid")
|
||||
m.Conf("vim", []string{"editor", name, "status"}, "logout")
|
||||
m.Conf("vim", []string{"editor", name, "time"}, m.Time())
|
||||
return
|
||||
|
||||
case "read", "write", "close":
|
||||
file := m.Option("arg")
|
||||
if !path.IsAbs(m.Option("arg")) {
|
||||
file = path.Join(m.Option("pwd"), m.Option("arg"))
|
||||
}
|
||||
|
||||
name := kit.Hashs(file, m.Option("hostname"), m.Option("username"))
|
||||
name := kit.Hashs(file)
|
||||
m.Conf("vim", []string{"opens", name, "path"}, file)
|
||||
m.Conf("vim", []string{"opens", name, "file"}, m.Option("arg"))
|
||||
m.Conf("vim", []string{"opens", name, "time"}, m.Time())
|
||||
m.Conf("vim", []string{"opens", name, "file"}, m.Option("arg"))
|
||||
m.Conf("vim", []string{"opens", name, "action"}, m.Option("cmd"))
|
||||
m.Conf("vim", []string{"opens", name, "pid"}, m.Option("pid"))
|
||||
m.Conf("vim", []string{"opens", name, "pwd"}, m.Option("pwd"))
|
||||
m.Conf("vim", []string{"opens", name, "pane"}, m.Option("pane"))
|
||||
m.Conf("vim", []string{"opens", name, "hostname"}, m.Option("hostname"))
|
||||
m.Conf("vim", []string{"opens", name, "username"}, m.Option("username"))
|
||||
m.Conf("vim", []string{"opens", name, "sid"}, m.Option("sid"))
|
||||
return
|
||||
case "sync":
|
||||
switch m.Option("arg") {
|
||||
case "fixs":
|
||||
if m.Conf("vim", []string{"fix", m.Option("sid")}, ""); strings.HasPrefix(m.Option("fixs"), "\nError") {
|
||||
break
|
||||
}
|
||||
m.Split(strings.TrimPrefix(m.Option("fixs"), "\n"), " ", "3", "id file text").Table(func(index int, value map[string]string) {
|
||||
vs := strings.Split(kit.Format(value["file"]), ":")
|
||||
m.Conf("vim", []string{"fix", m.Option("sid"), "-2"}, map[string]interface{}{
|
||||
"id": value["id"],
|
||||
"file": vs[0],
|
||||
"line": vs[1],
|
||||
"text": value["text"],
|
||||
})
|
||||
})
|
||||
m.Set("append").Set("result")
|
||||
case "tags":
|
||||
name := kit.Hashs(m.Option("hostname"), m.Option("username"))
|
||||
m.Conf("vim", []string{"tag", name}, "")
|
||||
|
||||
m.Conf("vim", []string{"tag", m.Option("sid")}, "")
|
||||
m.Split(strings.TrimPrefix(m.Option("tags"), "\n"), " ", "6").Table(func(index int, value map[string]string) {
|
||||
m.Conf("vim", []string{"tag", name, "-1"}, map[string]interface{}{
|
||||
"hostname": m.Option("hostname"),
|
||||
"username": m.Option("username"),
|
||||
"tag": value["tag"],
|
||||
"line": value["line"],
|
||||
"file": value["in file/text"],
|
||||
m.Conf("vim", []string{"tag", m.Option("sid"), "-2"}, map[string]interface{}{
|
||||
"tag": value["tag"],
|
||||
"line": value["line"],
|
||||
"file": value["in file/text"],
|
||||
})
|
||||
})
|
||||
m.Set("append").Set("result")
|
||||
case "bufs":
|
||||
name := kit.Hashs(m.Option("hostname"), m.Option("username"))
|
||||
m.Conf("vim", []string{"buffer", name}, "")
|
||||
|
||||
m.Split(m.Option("bufs"), " ", "5", "id tag name some line").Table(func(index int, value map[string]string) {
|
||||
m.Conf("vim", []string{"buffer", name, "-1"}, map[string]interface{}{
|
||||
"hostname": m.Option("hostname"),
|
||||
"username": m.Option("username"),
|
||||
"id": value["id"],
|
||||
"tag": value["tag"],
|
||||
"name": value["name"],
|
||||
"line": value["line"],
|
||||
m.Conf("vim", []string{"buffer", m.Option("sid")}, "")
|
||||
m.Split(strings.TrimSpace(m.Option("bufs")), " ", "5", "id tag name some line").Table(func(index int, value map[string]string) {
|
||||
m.Conf("vim", []string{"buffer", m.Option("sid"), "-2"}, map[string]interface{}{
|
||||
"id": value["id"],
|
||||
"tag": value["tag"],
|
||||
"name": value["name"],
|
||||
"line": value["line"],
|
||||
})
|
||||
})
|
||||
m.Set("append").Set("result")
|
||||
case "regs":
|
||||
name := kit.Hashs(m.Option("hostname"), m.Option("username"))
|
||||
m.Conf("vim", []string{"register", name}, "")
|
||||
|
||||
m.Conf("vim", []string{"register", m.Option("sid")}, "")
|
||||
m.Split(strings.TrimPrefix(m.Option("regs"), "\n--- Registers ---\n"), " ", "2", "name text").Table(func(index int, value map[string]string) {
|
||||
m.Conf("vim", []string{"register", name, "-1"}, map[string]interface{}{
|
||||
"hostname": m.Option("hostname"),
|
||||
"username": m.Option("username"),
|
||||
"text": strings.Replace(strings.Replace(value["text"], "^I", "\t", -1), "^J", "\n", -1),
|
||||
"name": strings.TrimPrefix(value["name"], "\""),
|
||||
m.Conf("vim", []string{"register", m.Option("sid"), "-2"}, map[string]interface{}{
|
||||
"text": strings.Replace(strings.Replace(value["text"], "^I", "\t", -1), "^J", "\n", -1),
|
||||
"name": strings.TrimPrefix(value["name"], "\""),
|
||||
})
|
||||
})
|
||||
m.Set("append").Set("result")
|
||||
@ -639,10 +704,9 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
}
|
||||
|
||||
switch m.Option("cmd") {
|
||||
case "read", "enter", "leave", "write":
|
||||
case "read", "write", "close":
|
||||
}
|
||||
return
|
||||
|
||||
}},
|
||||
},
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
kit shell "命令行" private "ssh._route" _ "context" "find" "web.code" "zsh" \
|
||||
text "" name pod imports plugin_pod \
|
||||
text "" name dir imports plugin_path action auto \
|
||||
select "" name cmd values list values find values tail values grep values init values terminal values history \
|
||||
select "terminal" name cmd values list values find values tail values grep values init values terminal values history \
|
||||
exports path path \
|
||||
text "" name txt \
|
||||
feature display editor \
|
||||
button "搜索" \
|
||||
button "搜索" action auto \
|
||||
button "返回" cb Last
|
||||
|
||||
kit clip "粘贴板" private "web.code.tmux" "" "" "" "buffer" \
|
||||
@ -33,36 +33,36 @@ kit image "镜像" private "web.code.docker" "image" \
|
||||
feature detail "运行" "删除" "清理" \
|
||||
button "查看"
|
||||
|
||||
kit container "容器" private "web.code.docker" "container" \
|
||||
text "" name arg imports plugin_CONTAINER_ID \
|
||||
exports CONTAINER_ID CONTAINER_ID \
|
||||
feature detail "进入" "停止" "启动" "重启" "修改" "删除" "清理" \
|
||||
button "查看" action auto
|
||||
|
||||
kit command "命令" private "web.code.docker" "container" \
|
||||
text "" name tag imports plugin_CONTAINER_ID \
|
||||
text "pwd" name cmd view long \
|
||||
button "执行"
|
||||
kit volume "存储" private "web.code.docker" "volume" \
|
||||
text "" name arg imports plugin_VOLUME_NAME \
|
||||
exports VOLUME_NAME VOLUME_NAME \
|
||||
button "查看"
|
||||
|
||||
kit network "网络" private "web.code.docker" "network" \
|
||||
text "" name arg imports plugin_NETWORK_ID action auto \
|
||||
exports NETWORK_ID NETWORK_ID \
|
||||
button "查看"
|
||||
|
||||
kit volume "存储" private "web.code.docker" "volume" \
|
||||
text "" name arg imports plugin_VOLUME_NAME \
|
||||
exports VOLUME_NAME VOLUME_NAME \
|
||||
button "查看"
|
||||
kit command "命令" private "web.code.docker" "container" \
|
||||
text "" name tag imports plugin_CONTAINER_ID \
|
||||
text "pwd" name cmd view long \
|
||||
button "执行"
|
||||
|
||||
kit container "容器" private "web.code.docker" "container" \
|
||||
text "" name arg imports plugin_CONTAINER_ID \
|
||||
exports CONTAINER_ID CONTAINER_ID \
|
||||
feature detail "进入" "停止" "启动" "重启" "修改" "删除" "清理" \
|
||||
button "查看" action auto
|
||||
|
||||
kit git "记录" private "ssh._route" _ "web.code.git" \
|
||||
text "" name pod imports plugin_pod \
|
||||
text "" name dir imports plugin_path action auto \
|
||||
select "" name cmd values diff values status values commit values branch values pull values push values sum values init \
|
||||
select "status" name cmd values diff values status values commit values branch values pull values push values sum values init \
|
||||
exports branch branch \
|
||||
button "查看"
|
||||
button "查看" action auto
|
||||
|
||||
kit vim "编辑器" private "ssh._route" _ "web.code.vim" \
|
||||
text "" name pod imports plugin_pod \
|
||||
select "" name cmd values opens values bufs values regs values tags \
|
||||
button "查看"
|
||||
select "bufs" name cmd values editor values opens values tags values fixs values bufs values regs \
|
||||
button "查看" action auto
|
||||
|
||||
|
@ -1080,6 +1080,14 @@ function Plugin(page, pane, field, inits, runs) {
|
||||
var list = option.querySelectorAll("input.temp")
|
||||
list.length > 0 && (option.removeChild(list[list.length-1].parentNode))
|
||||
}),
|
||||
Rename: shy("命名", function() {
|
||||
kit.prompt("控件名称", function(name) {
|
||||
meta["help"] = name
|
||||
kit.Selector(field, "legend", function(legend) {
|
||||
legend.innerHTML = meta.name+"("+meta.help+")"
|
||||
})
|
||||
})
|
||||
}),
|
||||
|
||||
Delete: shy("删除插件", function() {
|
||||
plugin.Prev().Plugin.Select(), field.parentNode.removeChild(field)
|
||||
@ -1244,8 +1252,9 @@ function Plugin(page, pane, field, inits, runs) {
|
||||
"返回": "Last",
|
||||
"清空": "clear",
|
||||
"克隆": "Clone",
|
||||
"重命名": "Rename",
|
||||
"删除": "Delete",
|
||||
}, ["返回", "清空", "克隆", "删除"], function(event, value, meta) {
|
||||
}, ["返回", "清空", "重命名", "克隆", "删除"], function(event, value, meta) {
|
||||
return plugin._call(meta[value], event)
|
||||
}),
|
||||
onaction: shy("事件列表", {
|
||||
|
Loading…
x
Reference in New Issue
Block a user