@@ -92,8 +92,10 @@ func main() {
92
92
if options .Config != "" {
93
93
configPath = options .Config
94
94
} else if options .Project != "" {
95
+
95
96
config , err := FindConfig (userConfigDir , options .Project )
96
- if err != nil && options .Command != CommandNew {
97
+
98
+ if err != nil && options .Command != CommandNew && options .Command != CommandStart && options .Command != CommandStop {
97
99
fmt .Fprintln (os .Stderr , err .Error ())
98
100
os .Exit (1 )
99
101
}
@@ -117,35 +119,48 @@ func main() {
117
119
} else {
118
120
fmt .Println ("Starting new windows..." )
119
121
}
120
-
121
- config , err := GetConfig (configPath , options .Settings , smug .tmux .TmuxOptions )
122
+ configs , err := FindConfigs (userConfigDir , options .Project )
122
123
if err != nil {
123
124
fmt .Fprint (os .Stderr , err .Error ())
124
125
os .Exit (1 )
125
126
}
126
-
127
- err = smug .Start (config , options , context )
128
- if err != nil {
129
- fmt .Println ("Oops, an error occurred! Rolling back..." )
130
- smug .Stop (config , options , context )
131
- os .Exit (1 )
127
+ for configIndex , configPath := range configs {
128
+ config , err := GetConfig (configPath , options .Settings , smug .tmux .TmuxOptions )
129
+ if err != nil {
130
+ fmt .Fprint (os .Stderr , err .Error ())
131
+ os .Exit (1 )
132
+ }
133
+ options .Detach = configIndex != len (configs )- 1
134
+ err = smug .Start (config , options , context )
135
+ if err != nil {
136
+ fmt .Println ("Oops, an error occurred! Rolling back..." )
137
+ smug .Stop (config , options , context )
138
+ os .Exit (1 )
139
+ }
132
140
}
133
141
case CommandStop :
134
142
if len (options .Windows ) == 0 {
135
143
fmt .Println ("Terminating session..." )
136
144
} else {
137
145
fmt .Println ("Killing windows..." )
138
146
}
139
- config , err := GetConfig ( configPath , options .Settings , smug . tmux . TmuxOptions )
147
+ configs , err := FindConfigs ( userConfigDir , options .Project )
140
148
if err != nil {
141
149
fmt .Fprint (os .Stderr , err .Error ())
142
150
os .Exit (1 )
143
151
}
144
-
145
- err = smug .Stop (config , options , context )
146
- if err != nil {
147
- fmt .Fprint (os .Stderr , err .Error ())
148
- os .Exit (1 )
152
+ for _ , configPath := range configs {
153
+ config , err := GetConfig (configPath , options .Settings , smug .tmux .TmuxOptions )
154
+ if err != nil {
155
+ fmt .Fprint (os .Stderr , err .Error ())
156
+ os .Exit (1 )
157
+ }
158
+
159
+ err = smug .Stop (config , options , context )
160
+ if err != nil {
161
+ fmt .Fprint (os .Stderr , err .Error ())
162
+ os .Exit (1 )
163
+ }
149
164
}
150
165
case CommandNew , CommandEdit :
151
166
err := EditConfig (configPath )
@@ -154,7 +169,7 @@ func main() {
154
169
os .Exit (1 )
155
170
}
156
171
case CommandList :
157
- configs , err := ListConfigs (userConfigDir )
172
+ configs , err := ListConfigs (userConfigDir , true )
158
173
if err != nil {
159
174
fmt .Fprint (os .Stderr , err .Error ())
160
175
os .Exit (1 )
@@ -163,6 +178,24 @@ func main() {
163
178
for _ , config := range configs {
164
179
fileExt := path .Ext (config )
165
180
fmt .Println (strings .TrimSuffix (config , fileExt ))
181
+ isDir , err := IsDirectory (userConfigDir + "/" + config )
182
+ if err != nil {
183
+ continue
184
+ }
185
+ if isDir {
186
+
187
+ subConfigs , err := ListConfigs (userConfigDir + "/" + config , false )
188
+ if err != nil {
189
+ fmt .Fprint (os .Stderr , err .Error ())
190
+ os .Exit (1 )
191
+ }
192
+ for _ , subConfig := range subConfigs {
193
+ fileExt := path .Ext (subConfig )
194
+ fmt .Println ("|--" + strings .TrimSuffix (subConfig , fileExt ))
195
+ }
196
+
197
+ }
198
+
166
199
}
167
200
168
201
case CommandPrint :
0 commit comments