@@ -14,6 +14,7 @@ import (
14
14
"github.com/gorilla/websocket"
15
15
"github.com/rjeczalik/notify"
16
16
"go.coder.com/flog"
17
+ "golang.org/x/crypto/ssh/terminal"
17
18
"golang.org/x/xerrors"
18
19
19
20
"cdr.dev/coder-cli/internal/entclient"
@@ -156,6 +157,13 @@ func (s Sync) work(ev notify.EventInfo) {
156
157
}
157
158
}
158
159
160
+ func setConsoleTitle (title string ) {
161
+ if ! terminal .IsTerminal (int (os .Stdout .Fd ())) {
162
+ return
163
+ }
164
+ fmt .Printf ("\033 ]0;%s\007 " , title )
165
+ }
166
+
159
167
// maxinflightInotify sets the maximum number of inotifies before the sync just restarts.
160
168
// Syncing a large amount of small files (e.g .git or node_modules) is impossible to do performantly
161
169
// with individual rsyncs.
@@ -164,6 +172,7 @@ const maxInflightInotify = 16
164
172
var ErrRestartSync = errors .New ("the sync exited because it was overloaded, restart it" )
165
173
166
174
func (s Sync ) Run () error {
175
+ setConsoleTitle ("⏳ syncing project" )
167
176
err := s .initSync ()
168
177
if err != nil {
169
178
return err
@@ -182,12 +191,19 @@ func (s Sync) Run() error {
182
191
}
183
192
defer notify .Stop (events )
184
193
194
+
195
+ const watchingFilesystemTitle = "🛰 watching filesystem"
196
+ setConsoleTitle (watchingFilesystemTitle )
197
+
185
198
flog .Info ("watching %s for changes" , s .LocalDir )
186
199
for ev := range events {
187
200
if len (events ) > maxInflightInotify {
188
201
return ErrRestartSync
189
202
}
203
+
204
+ setConsoleTitle ("🚀 updating " + filepath .Base (ev .Path ()))
190
205
s .work (ev )
206
+ setConsoleTitle (watchingFilesystemTitle )
191
207
}
192
208
193
209
return nil
0 commit comments