Use tmux session name in print command(#52)

master
Pim Snel 3 years ago committed by GitHub
parent 756faa8e1a
commit d3f5d57af4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -168,7 +168,12 @@ func (smug Smug) Start(config Config, options Options, context Context) error {
func (smug Smug) GetConfigFromSession(options Options, context Context) (Config, error) {
config := Config{}
config.Session = options.Project
tmuxSession, err := smug.tmux.SessionName()
if err != nil {
return Config{}, err
}
config.Session = tmuxSession
tmuxWindows, err := smug.tmux.ListWindows(options.Project)
if err != nil {

@ -349,7 +349,7 @@ func TestStartStopSession(t *testing.T) {
func TestPrintCurrentSession(t *testing.T) {
expectedConfig := Config{
Session: "test",
Session: "session_name",
Windows: []Window{
Window{
Name: "win1",
@ -366,6 +366,7 @@ func TestPrintCurrentSession(t *testing.T) {
}
commander := &MockCommander{[]string{}, []string{
"session_name",
"id1;win1;layout;root",
"root\n/tmp",
}}

@ -115,6 +115,18 @@ func (tmux Tmux) SwitchClient(target string) error {
return tmux.commander.ExecSilently(cmd)
}
func (tmux Tmux) SessionName() (string, error) {
cmd := exec.Command("tmux", "display-message", "-p", "#S")
sessionName, err := tmux.commander.Exec(cmd)
if err != nil {
return sessionName, err
}
return sessionName, nil
}
func (tmux Tmux) ListWindows(target string) ([]TmuxWindow, error) {
var windows []TmuxWindow

Loading…
Cancel
Save