2022-03-25 23:59:01 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2022-04-06 13:45:46 +00:00
|
|
|
Z "github.com/rwxrob/bonzai/z"
|
2022-04-09 08:50:54 +00:00
|
|
|
"github.com/rwxrob/help"
|
2022-04-11 09:51:59 +00:00
|
|
|
"github.com/rwxrob/vars"
|
2022-03-25 23:59:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var tmux = &Z.Cmd{
|
|
|
|
Name: `tmux`,
|
|
|
|
Summary: `make tmux updates`,
|
2022-04-15 15:35:29 +00:00
|
|
|
Commands: []*Z.Cmd{help.Cmd, tmuxUpdate, vars.Cmd, in},
|
|
|
|
}
|
|
|
|
|
|
|
|
var in = &Z.Cmd{
|
|
|
|
Name: `in`,
|
|
|
|
Summary: `exec a nested tmux session (unset TMUX)`,
|
|
|
|
Usage: `[help|<tmuxarg>...]`,
|
|
|
|
Commands: []*Z.Cmd{help.Cmd},
|
|
|
|
Call: func(_ *Z.Cmd, args ...string) error {
|
|
|
|
home, err := os.UserHomeDir()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
conf := path.Join(home, `.tmux.conf`)
|
|
|
|
tmuxargs := []string{`tmux`, `-f`, conf, `-u`}
|
|
|
|
tmuxargs = append(tmuxargs, args...)
|
|
|
|
os.Unsetenv(`TMUX`)
|
|
|
|
Z.SysExec(tmuxargs...)
|
|
|
|
return nil
|
|
|
|
},
|
2022-03-25 23:59:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var tmuxUpdate = &Z.Cmd{
|
|
|
|
Name: `update`,
|
|
|
|
Summary: `update the onscreen status`,
|
|
|
|
Call: func(_ *Z.Cmd, args ...string) error {
|
|
|
|
msg := strings.Join(args, " ")
|
|
|
|
return Z.Exec(
|
|
|
|
"tmux", "-L", "live", "set", "-g", "status-right", msg,
|
|
|
|
)
|
|
|
|
},
|
|
|
|
}
|