Skip to content
/ goportal Public

Send command to another terminal that running goportal.

License

Notifications You must be signed in to change notification settings

cfrco/goportal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goportal

Send command to another terminal that running goportal in Go.

Motivation

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.

Installation

Install or update

go get -u github.com/cfrco/goportal

Usage

Start a Receiver

goportal -r <name>

End a Receiver

Always use this command to end receiver. For sure it remove FIFO files.

goportal -i <name> end

Use Sender to send command

Normal command

goportal <name> <command...>

Redo previous command

goportal <name>

Send goportal interanl command

goportal -i <name> <internal_cmd> <args...>

Send non-processed command

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.

Internal Command

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

Vim:vim-goportal

Install

cp -r vim ~/.vim/bundle/vim-goportal

Usage

  • :Gpd : set/display the default name
  • :Gpdd : clear the default name
  • :Gp : normal command
  • :Gpi : internal command
  • :Gpo : original command
  • :Gpa : call saved command
  • function GoPortal(...)
  • function GoPortalDefault(...)

Example

# 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

About

Send command to another terminal that running goportal.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages