Send command to another terminal that running goportal in Go.
Since continuously, I hope i can run a shell in Vim. But i don't find a good solution. One day, I find tslime.vim
(https://github.com/jgdavey/tslime.vim). But i don't use tmux
. So I think I can write a program send command from terminal to terminal.
Install or update
go get -u github.com/cfrco/goportal
goportal -r <name>
Always use this command to end receiver. For sure it remove FIFO files.
goportal -i <name> end
goportal <name> <command...>
goportal <name>
goportal -i <name> <internal_cmd> <args...>
Normally, goportal
automatically add "
for each argument.
For example,ls -al
will be "ls" "-al"
and echo '"hello world!"'
will be "echo" "\"hello world\""
.
It's OK for those case. But it may cause problem in some case.(ls -al | grep go
=> "ls" "-al" "|" "grep" "go"
).
And pipeline can't work. In this case, use -o
.
goportal -o test ls -al "|" grep go
IMPORTANT : |
should be "|"
,or it will be pipeline's redirection for goportal -o test ls -al
.
goportal -i <name> cd <path> # change directory.
goportal -i <name> ret # display `$?`(the last command's return value).
goportal -i <name> history # display history commands.
goportal -i <name> end # end the receiver.
goportal -i <name> set "<var-name> = <command>"
# save command
goportal -i <name> @ <var-name> # call command
goportal -i <name> ls # list all saved commands
cp -r vim ~/.vim/bundle/vim-goportal
:Gpd
: set/display the default name:Gpdd
: clear the default name:Gp
: normal command:Gpi
: internal command:Gpo
: original command:Gpa
: call saved commandfunction GoPortal(...)
function GoPortalDefault(...)
# terminal
$ goportal -r test
# vim
:Gpd test
:Gp gcc test.c -o test
:Gpo gcc test.c -o test ";" ./test
:Gpi end
:Gpi set "l=ls -al"
:Gpa l