1
0
forked from x/ContextOS

mac opt ssh.send

This commit is contained in:
shaoying 2018-10-09 09:39:22 +08:00
parent 15d4da1b18
commit 0a01fe3f0c
4 changed files with 60 additions and 13 deletions

View File

@ -127,6 +127,7 @@ set keywordprg=man\ -a
autocmd BufNewFile,BufReadPost *.shy set filetype=shy
autocmd BufNewFile,BufReadPost *.shy set commentstring=#%s
autocmd BufNewFile,BufReadPost *.conf set filetype=nginx
autocmd BufNewFile,BufReadPost *.go set foldmethod=syntax
command! RR wa | source ~/.vimrc |e

View File

@ -51,7 +51,7 @@ ZSH_THEME="robbyrussell"
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(tmux git)
plugins=(tmux docker git)
source $ZSH/oh-my-zsh.sh
source ~/.oh-my-zsh/plugins/z/z.sh

View File

@ -100,7 +100,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
if _, ok := m.Target().Server.(*SSH); m.Assert(ok) {
m.Sess("nfs").Call(func(sub *ctx.Message) *ctx.Message {
sub.Start(fmt.Sprintf("host%d", Pulse.Capi("nhost", 1)), "远程主机")
// sub.Spawn().Cmd("pwd", "init")
sub.Spawn().Cmd("pwd", "")
return sub
}, m.Meta["detail"])
if !m.Caps("domain") {
@ -123,21 +123,62 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
domain := ""
if len(arg) > 1 && arg[0] == "domain" {
domain, arg = arg[1], arg[2:]
domain = strings.TrimPrefix(strings.TrimPrefix(domain, m.Cap("domain")), ".")
}
if d := strings.TrimPrefix(domain, m.Cap("domain")); len(d) > 0 && d[0] == '.' {
domain = d[1:]
} else if d == "" {
domain = d
}
if m.Has("send_code") {
msg := m.Spawn().Cmd(arg)
m.Copy(msg, "result").Copy(msg, "append")
if domain == "" {
msg := m.Spawn().Cmd(arg)
m.Copy(msg, "result").Copy(msg, "append")
return
}
} else {
msg := m.Spawn(ssh.Message().Source())
msg.Cmd("send", arg)
m.Copy(msg, "result").Copy(msg, "append")
if m.Has("send_code") {
msg := m.Spawn().Cmd(arg)
m.Copy(msg, "result").Copy(msg, "append")
} else {
msg := m.Spawn(ssh.Message().Source())
msg.Cmd("send", arg)
m.Copy(msg, "result").Copy(msg, "append")
}
return
}
return
miss := true
host := strings.SplitN(domain, ".", 2)
m.Travel(func(m *ctx.Message, i int) bool {
if i == 0 {
return true
}
if m.Cap("hostname") == host[0] {
if len(host) > 1 {
ssh, ok := m.Target().Server.(*SSH)
m.Assert(ok)
msg := m.Spawn(ssh.Message().Source())
msg.Cmd("send", "domain", host[1], arg)
m.Copy(msg, "result").Copy(msg, "append")
} else {
msg := m.Spawn()
msg.Cmd("send", arg)
m.Copy(msg, "result").Copy(msg, "append")
}
miss = false
return false
}
return true
}, c)
if miss {
msg := m.Spawn(c.Message().Source())
msg.Cmd("send", "domain", domain, arg)
m.Copy(msg, "result").Copy(msg, "append")
}
return
if domain != "" {
domain_miss := true
host := strings.SplitN(domain, ".", 2)

View File

@ -4,6 +4,7 @@ import (
"contexts"
"crypto/tls"
"fmt"
"io"
"net"
"strconv"
"strings"
@ -20,7 +21,9 @@ func (tcp *TCP) Read(b []byte) (n int, e error) {
m.Assert(tcp.Conn != nil)
n, e = tcp.Conn.Read(b)
m.Capi("nrecv", n)
m.Assert(e)
if e != io.EOF {
m.Assert(e)
}
return
}
func (tcp *TCP) Write(b []byte) (n int, e error) {
@ -28,7 +31,9 @@ func (tcp *TCP) Write(b []byte) (n int, e error) {
m.Assert(tcp.Conn != nil)
n, e = tcp.Conn.Write(b)
m.Capi("nsend", n)
m.Assert(e)
if e != io.EOF {
m.Assert(e)
}
return
}