diff --git a/base/cli/cli.go b/base/cli/cli.go index 7b4c47bc..95d69bd4 100644 --- a/base/cli/cli.go +++ b/base/cli/cli.go @@ -90,6 +90,19 @@ var Index = &ice.Context{Name: "cli", Help: "命令模块", if len(cmd.Env) > 0 { m.Info("env: %s", cmd.Env) } + if m.Option("cmd_stdout") != "" { + if f, p, e := kit.Create(m.Option("cmd_stdout")); m.Assert(e) { + m.Info("stdout: %s", p) + cmd.Stdout = f + cmd.Stderr = f + } + } + if m.Option("cmd_stderr") != "" { + if f, p, e := kit.Create(m.Option("cmd_stderr")); m.Assert(e) { + m.Info("stderr: %s", p) + cmd.Stderr = f + } + } switch m.Option("cmd_type") { case "daemon": diff --git a/conf.go b/conf.go index ec354765..77936024 100644 --- a/conf.go +++ b/conf.go @@ -187,6 +187,10 @@ const ( // TYPE TYPE_INNER = "inner" TYPE_MEDIA = "media" ) +const ( // CODE + CODE_INSTALL = "_install" + CODE_PREPARE = "_prepare" +) const ( // CHAT CHAT_RIVER = "river" CHAT_STORM = "storm" diff --git a/core/code/code.go b/core/code/code.go index c2c22e3e..aab0e206 100644 --- a/core/code/code.go +++ b/core/code/code.go @@ -16,6 +16,19 @@ import ( var Index = &ice.Context{Name: "code", Help: "编程中心", Caches: map[string]*ice.Cache{}, Configs: map[string]*ice.Config{ + "prepare": {Name: "prepare", Help: "准备", Value: kit.Data("path", "usr/prepare", + "tool", kit.Dict( + "vim", []interface{}{ + "wget ftp://ftp.vim.org/pub/vim/unix/vim-8.1.tar.bz2", + "tar xvf vim-8.1.tar.bz2", + "cd vim81", + + "./configure --prefix=/home/shaoying/usr/vim --enable-multibyte=yes --enable-cscope=yes --enable-luainterp=yes --enable-pythoninterp=yes", + "make -j4", + "make install", + }, + ), + )}, "compile": {Name: "compile", Help: "编译", Value: kit.Data("path", "usr/publish")}, "publish": {Name: "publish", Help: "发布", Value: kit.Data("path", "usr/publish")}, "upgrade": {Name: "upgrade", Help: "升级", Value: kit.Dict(kit.MDB_HASH, kit.Dict( @@ -127,6 +140,15 @@ var Index = &ice.Context{Name: "code", Help: "编程中心", } }}, + ice.CODE_INSTALL: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }}, + ice.CODE_PREPARE: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + m.Cmd(ice.CLI_SYSTEM, "go", "get", "github.com/gotags") + }}, + "prepare": {Name: "prepare", Help: "准备", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + + }}, + "compile": {Name: "compile [os [arch]]", Help: "编译", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { if len(arg) == 0 { // 目录列表 diff --git a/misc/vim/vim.go b/misc/vim/vim.go index dd497c63..ad0addc9 100644 --- a/misc/vim/vim.go +++ b/misc/vim/vim.go @@ -13,10 +13,37 @@ import ( var Index = &ice.Context{Name: "vim", Help: "编辑器", Caches: map[string]*ice.Cache{}, Configs: map[string]*ice.Config{ - "vim": {Name: "vim", Help: "编辑器", Value: kit.Data(kit.MDB_SHORT, "name", "history", "vim.history")}, + "vim": {Name: "vim", Help: "编辑器", Value: kit.Data( + kit.MDB_SHORT, "name", "history", "vim.history", + "version", "vim81", + "source", "ftp://ftp.vim.org/pub/vim/unix/vim-8.1.tar.bz2", + "script", "", + )}, }, Commands: map[string]*ice.Command{ - ice.WEB_LOGIN: {Name: "_login", Help: "_login", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + ice.CODE_INSTALL: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + msg := m.Cmd(ice.WEB_SPIDE, "dev", "cache", m.Conf("vim", "meta.source")) + m.Cmd(ice.WEB_CACHE, "watch", msg.Append("data"), "usr/vim.tar.gz") + + m.Option("cmd_dir", "usr") + m.Cmd(ice.CLI_SYSTEM, "tar", "xvf", "vim.tar.gz") + m.Option("cmd_dir", "usr/"+m.Conf("vim", "meta.version")) + m.Cmd(ice.CLI_SYSTEM, "./configure", + "--prefix="+kit.Path("usr/vim"), + "--enable-multibyte=yes", + "--enable-cscope=yes", + "--enable-luainterp=yes", + "--enable-pythoninterp=yes", + ) + + m.Cmd(ice.CLI_SYSTEM, "make", "-j4") + m.Cmd(ice.CLI_SYSTEM, "make", "install") + }}, + ice.CODE_PREPARE: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + + }}, + + ice.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { if f, _, e := m.R.FormFile("sub"); e == nil { defer f.Close() if b, e := ioutil.ReadAll(f); e == nil { diff --git a/misc/vim/vim.shy b/misc/vim/vim.shy index 789c8d33..3eeca6ff 100644 --- a/misc/vim/vim.shy +++ b/misc/vim/vim.shy @@ -1 +1,24 @@ title "vim" + +refer "官网" ` +官网 https://www.vim.org/ +下载 https://www.vim.org/download.php +源码 ftp://ftp.vim.org/pub/vim/unix/vim-8.1.tar.bz2 +` +chapter "安装" +spark "下载" ` +wget ftp://ftp.vim.org/pub/vim/unix/vim-8.1.tar.bz2 +tar xvf vim-8.1.tar.bz2 +cd vim81 +` + +spark "安装" ` +yum install gcc +yum install python-devel +` + +spark "编译" ` +./configure --prefix=/home/shaoying/usr/vim --enable-multibyte=yes --enable-cscope=yes --enable-luainterp=yes --enable-pythoninterp=yes +make -j4 +make install +` diff --git a/misc/zsh/auto.sh b/misc/zsh/auto.sh index ac83063a..e06e7501 100644 --- a/misc/zsh/auto.sh +++ b/misc/zsh/auto.sh @@ -82,30 +82,37 @@ ShyLogout() { } # 发送文件 -ShyDownload() { - ${ctx_curl} -s "${ctx_url}download" -F "cmds=$1" \ - -F "SHELL=${SHELL}" -F "pwd=${PWD}" -F "sid=${ctx_sid}" -} -ShyUpload() { - ${ctx_curl} -s "${ctx_url}upload" -F "upload=@$1" \ - -F "SHELL=${SHELL}" -F "pwd=${PWD}" -F "sid=${ctx_sid}" -} ShySend() { local TEMP=`mktemp /tmp/tmp.XXXXXX` && "$@" > $TEMP ShyRight "$ctx_silent" || cat $TEMP ${ctx_curl} -s "${ctx_url}sync" -F "cmds=$1" -F "cmds=$*" -F "sub=@$TEMP" \ -F "SHELL=${SHELL}" -F "pwd=${PWD}" -F "sid=${ctx_sid}" } - -ShyLocal() { - which=alpine && [ "$1" != "" ] && which=$1 && shift - favor=tmux.auto && [ "$1" != "" ] && favor=$1 && shift - step=before arg="" && for cmd in "$@"; do - [ "$cmd" = after ] && step=after && continue - arg="$arg&$step="`ShyWord $cmd` - done - ${ctx_curl} -s "$ctx_dev/code/tmux/favor?local=$which&cmds=$favor&$arg" & +ShyUpload() { + ${ctx_curl} -s "${ctx_url}upload" -F "upload=@$1" \ + -F "SHELL=${SHELL}" -F "pwd=${PWD}" -F "sid=${ctx_sid}" } +ShyDownload() { + ${ctx_curl} -s "${ctx_url}download" -F "cmds=$1" \ + -F "SHELL=${SHELL}" -F "pwd=${PWD}" -F "sid=${ctx_sid}" +} +ShyInstall() { + case "$1" in + "vim") + # git vim + curl -fLo ~/.vimrc https://raw.githubusercontent.com/shylinux/contexts/master/etc/conf/vimrc + curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + vim -c PlugInstall + ;; + *) + ;; + esac +} +ShyUpgrade() { + file=auto.sh && [ "$1" != "" ] && file=$1 + ${ctx_curl} -s $ctx_dev/publish/$file > $file && source auto.sh +} + ShyRelay() { which=relay && [ "$1" != "" ] && which=$1 && shift favor=tmux.auto && [ "$1" != "" ] && favor=$1 && shift @@ -115,7 +122,35 @@ ShyRelay() { done ${ctx_curl} -s "$ctx_dev/code/tmux/favor?relay=$which&cmds=$favor&$arg" & } - +ShyLocal() { + which=alpine && [ "$1" != "" ] && which=$1 && shift + favor=tmux.auto && [ "$1" != "" ] && favor=$1 && shift + step=before arg="" && for cmd in "$@"; do + [ "$cmd" = after ] && step=after && continue + arg="$arg&$step="`ShyWord $cmd` + done + ${ctx_curl} -s "$ctx_dev/code/tmux/favor?local=$which&cmds=$favor&$arg" & +} +ShyFavor() { + cmd=$1; [ "$READLINE_LINE" != "" ] && set $READLINE_LINE && READLINE_LINE="" + if [ "$cmd" = "sh" ] ; then + # 查看收藏 + ctx_word="sh" + shift && [ "$1" != "" ] && ctx_tab="$1" + shift && ctx_note="$1" + else + # 添加收藏 + [ "$1" != "" ] && ctx_word="$*" || ctx_word=`history|tail -n1|head -n1|sed -e 's/^[\ 0-9]*//g'` + fi + ShyPost favor "${ctx_word}" tab "${ctx_tab}" note "${ctx_note}" +} +ShyInput() { + if [ "$1" = "line" ] ; then + READLINE_LINE=`ShyPost input "$1" line "$READLINE_LINE" point "$READLINE_POINT"` + else + COMPREPLY=(`ShyPost input "$COMP_WORDS" line "$COMP_LINE" index "$COMP_CWORD" break "$COMP_WORDBREAKS"`) + fi +} # 同步数据 ShySync() { case "$1" in @@ -140,31 +175,6 @@ ShySync() { *) ShySend "$@" esac } -ShyInput() { - if [ "$1" = "line" ] ; then - READLINE_LINE=`ShyPost input "$1" line "$READLINE_LINE" point "$READLINE_POINT"` - else - COMPREPLY=(`ShyPost input "$COMP_WORDS" line "$COMP_LINE" index "$COMP_CWORD" break "$COMP_WORDBREAKS"`) - fi -} -ShyFavor() { - cmd=$1; [ "$READLINE_LINE" != "" ] && set $READLINE_LINE && READLINE_LINE="" - if [ "$cmd" = "sh" ] ; then - # 查看收藏 - ctx_word="sh" - shift && [ "$1" != "" ] && ctx_tab="$1" - shift && ctx_note="$1" - else - # 添加收藏 - [ "$1" != "" ] && ctx_word="$*" || ctx_word=`history|tail -n1|head -n1|sed -e 's/^[\ 0-9]*//g'` - fi - ShyPost favor "${ctx_word}" tab "${ctx_tab}" note "${ctx_note}" -} - -ShyUpgrade() { - file=auto.sh && [ "$1" != "" ] && file=$1 - ${ctx_curl} -s $ctx_dev/publish/$file > $file && source auto.sh -} ShyInit() { [ "$ctx_begin" = "" ] && ctx_begin=`history|tail -n1|awk '{print $1}'` diff --git a/misc/zsh/zsh.go b/misc/zsh/zsh.go index 410377f7..68160b3e 100644 --- a/misc/zsh/zsh.go +++ b/misc/zsh/zsh.go @@ -26,10 +26,9 @@ var Index = &ice.Context{Name: "zsh", Help: "命令行", } } - m.Option("you", "tmux") + // 查找空间 m.Richs("login", nil, m.Option("sid"), func(key string, value map[string]interface{}) { - // 查找空间 - m.Option("you", value["you"]) + m.Option("you", kit.Select("tmux", value["you"])) }) m.Info("%s %s cmd: %v sub: %v", m.Option("you"), m.Option(ice.MSG_USERURL), m.Optionv("cmds"), m.Optionv("sub"))