@seflless/ghosttown 1.3.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/assets/ghosts.png +0 -0
- package/package.json +1 -1
- package/src/cli.js +56 -22
package/bin/assets/ghosts.png
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -55,22 +55,18 @@ function checkTmuxInstalled() {
|
|
|
55
55
|
* Print tmux installation instructions and exit
|
|
56
56
|
*/
|
|
57
57
|
function printTmuxInstallHelp() {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
console.error(' \x1b[36mmacOS (Homebrew):\x1b[0m brew install tmux');
|
|
64
|
-
console.error(' \x1b[36mmacOS (MacPorts):\x1b[0m sudo port install tmux');
|
|
65
|
-
} else if (process.platform === 'linux') {
|
|
66
|
-
console.error(' \x1b[36mDebian/Ubuntu:\x1b[0m sudo apt install tmux');
|
|
67
|
-
console.error(' \x1b[36mFedora:\x1b[0m sudo dnf install tmux');
|
|
68
|
-
console.error(' \x1b[36mArch:\x1b[0m sudo pacman -S tmux');
|
|
69
|
-
} else {
|
|
70
|
-
console.error(' Please install tmux using your system package manager.');
|
|
71
|
-
}
|
|
58
|
+
const RESET = '\x1b[0m';
|
|
59
|
+
const RED = '\x1b[31m';
|
|
60
|
+
const CYAN = '\x1b[36m';
|
|
61
|
+
const BEIGE = '\x1b[38;2;255;220;150m';
|
|
62
|
+
const DIM = '\x1b[2m';
|
|
72
63
|
|
|
73
|
-
console.
|
|
64
|
+
console.log('');
|
|
65
|
+
console.log(` ${RED}ghosttown needs tmux to be installed.${RESET}`);
|
|
66
|
+
console.log(` ${DIM}tmux is used to manage terminal sessions.${RESET}`);
|
|
67
|
+
console.log('');
|
|
68
|
+
console.log(` ${CYAN}To install:${RESET} ${BEIGE}brew install tmux${RESET}`);
|
|
69
|
+
console.log('');
|
|
74
70
|
process.exit(1);
|
|
75
71
|
}
|
|
76
72
|
|
|
@@ -329,13 +325,7 @@ function detachFromTmux() {
|
|
|
329
325
|
if (clientTty) {
|
|
330
326
|
result = spawnSync(
|
|
331
327
|
'tmux',
|
|
332
|
-
[
|
|
333
|
-
'detach-client',
|
|
334
|
-
'-t',
|
|
335
|
-
clientTty,
|
|
336
|
-
'-E',
|
|
337
|
-
`printf %s '${messageForShell}'`,
|
|
338
|
-
],
|
|
328
|
+
['detach-client', '-t', clientTty, '-E', `printf %s '${messageForShell}'`],
|
|
339
329
|
{
|
|
340
330
|
stdio: 'inherit',
|
|
341
331
|
}
|
|
@@ -416,6 +406,41 @@ function attachToSession(sessionName) {
|
|
|
416
406
|
process.exit(result.status || 0);
|
|
417
407
|
}
|
|
418
408
|
|
|
409
|
+
/**
|
|
410
|
+
* Update ghosttown to the latest version
|
|
411
|
+
*/
|
|
412
|
+
function updateGhosttown() {
|
|
413
|
+
const RESET = '\x1b[0m';
|
|
414
|
+
const CYAN = '\x1b[36m';
|
|
415
|
+
const BEIGE = '\x1b[38;2;255;220;150m';
|
|
416
|
+
const BOLD_YELLOW = '\x1b[1;93m';
|
|
417
|
+
const DIM = '\x1b[2m';
|
|
418
|
+
|
|
419
|
+
console.log('');
|
|
420
|
+
console.log(` ${BOLD_YELLOW}Updating ghosttown...${RESET}`);
|
|
421
|
+
console.log('');
|
|
422
|
+
|
|
423
|
+
try {
|
|
424
|
+
execSync('npm install -g @seflless/ghosttown', {
|
|
425
|
+
stdio: 'inherit',
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
console.log('');
|
|
429
|
+
console.log(` ${BOLD_YELLOW}ghosttown has been updated!${RESET}`);
|
|
430
|
+
console.log('');
|
|
431
|
+
console.log(` ${CYAN}To check your version:${RESET} ${BEIGE}ghosttown --version${RESET}`);
|
|
432
|
+
console.log('');
|
|
433
|
+
} catch (err) {
|
|
434
|
+
console.log('');
|
|
435
|
+
console.log(` ${RESET}Failed to update ghosttown.${RESET}`);
|
|
436
|
+
console.log(` ${DIM}Try running with sudo: sudo npm install -g @seflless/ghosttown${RESET}`);
|
|
437
|
+
console.log('');
|
|
438
|
+
process.exit(1);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
process.exit(0);
|
|
442
|
+
}
|
|
443
|
+
|
|
419
444
|
/**
|
|
420
445
|
* Kill a ghosttown session
|
|
421
446
|
* If sessionName is null, kills the current session (if inside one)
|
|
@@ -537,6 +562,7 @@ Commands:
|
|
|
537
562
|
list List all ghosttown tmux sessions
|
|
538
563
|
attach <session> Attach to a ghosttown session
|
|
539
564
|
detach Detach from current ghosttown session
|
|
565
|
+
update Update ghosttown to the latest version
|
|
540
566
|
<command> Run command in a new tmux session (ghosttown-<id>)
|
|
541
567
|
|
|
542
568
|
Examples:
|
|
@@ -545,6 +571,7 @@ Examples:
|
|
|
545
571
|
ghosttown list List all ghosttown sessions
|
|
546
572
|
ghosttown attach ghosttown-1 Attach to session ghosttown-1
|
|
547
573
|
ghosttown detach Detach from current session
|
|
574
|
+
ghosttown update Update to the latest version
|
|
548
575
|
ghosttown -k Kill current session (when inside one)
|
|
549
576
|
ghosttown -k ghosttown-1 Kill a specific session
|
|
550
577
|
ghosttown vim Run vim in a new tmux session
|
|
@@ -571,6 +598,13 @@ Aliases:
|
|
|
571
598
|
// detachFromTmux exits, so this won't be reached
|
|
572
599
|
}
|
|
573
600
|
|
|
601
|
+
// Handle update command
|
|
602
|
+
else if (arg === 'update') {
|
|
603
|
+
handled = true;
|
|
604
|
+
updateGhosttown();
|
|
605
|
+
// updateGhosttown exits, so this won't be reached
|
|
606
|
+
}
|
|
607
|
+
|
|
574
608
|
// Handle attach command
|
|
575
609
|
else if (arg === 'attach') {
|
|
576
610
|
const sessionArg = args[i + 1];
|