-
Notifications
You must be signed in to change notification settings - Fork 2
/
linux.mjs
42 lines (35 loc) · 1.18 KB
/
linux.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { $ } from 'zx';
import { commandExists, $swallow, $silent } from './src/shell.mjs';
import { dir } from './src/path.mjs';
import { OK } from './src/log.mjs';
if (!(await commandExists('apt-get'))) {
console.log('apt-get not available, and other installers are not support. Silently ignoring Linux setup...');
process.exit(0);
}
console.log('Executing the Linux specific setup...');
if (!(await commandExists('starship'))) {
await $`curl -sS https://starship.rs/install.sh | sh`;
} else {
OK`starship already installed.`;
}
await $`sudo apt-get update`;
await $`sudo apt-get install -y neovim tmux git fish rsync ripgrep fzf bat`;
// fish
const fishPath = (await $silent`which fish`).stdout.trim();
const isFishInstalled = Boolean(
(await $swallow`grep ${fishPath} /etc/shells`).stdout
);
if (!isFishInstalled) {
console.log('Setting up fish...');
await $`echo ${fishPath} | sudo tee -a /etc/shells`;
OK`fish installed.`;
} else {
OK`fish already installed.`;
}
if (process.env.SHELL !== fishPath) {
console.log('Defining fish as the default shell...');
await $`chsh -s ${fishPath}`;
OK`fish is now the default shell.`;
} else {
OK`fish is already the default shell.`;
}