summaryrefslogtreecommitdiff
path: root/install/vscode.fish
blob: 8d4aa6cf7f4b75c39c6837f217b51907fec4ac17 (plain)
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
43
#!/bin/fish

. (dirname (status filename))/util.fish

function confirm-copy -a from to
    test -L $to -a "$(realpath $to 2> /dev/null)" = (realpath $from) && return  # Return if symlink
    cmp $from $to 2> /dev/null && return  # Return if files are the same
    if test -e $to
        read -l -p "input '$(realpath $to) already exists. Overwrite? [y/N] ' -n" confirm
        test "$confirm" = 'y' -o "$confirm" = 'Y' && log 'Continuing.' || return
    end
    cp $from $to
end

install-deps git

set -l dist $C_DATA/vscode

# Update/Clone repo
update-repo vscode $dist

# Install settings
for prog in 'Code' 'Code - OSS' 'VSCodium'
    set -l conf $CONFIG/$prog
    if test -d $conf
        confirm-copy $dist/settings.json $conf/User/settings.json
        confirm-copy $dist/keybindings.json $conf/User/keybindings.json
    end
end

# Install extension
for prog in code code-insiders codium
    if which $prog &> /dev/null
        log "Installing extensions for '$prog'"
        if ! contains 'catppuccin.catppuccin-vsc-icons' ($prog --list-extensions)
            read -l -p "input 'Install catppuccin icons (for light/dark integration)? [Y/n] ' -n" confirm
            test "$confirm" = 'n' -o "$confirm" = 'N' || $prog --install-extension catppuccin.catppuccin-vsc-icons
        end
        $prog --install-extension $dist/caelestia-vscode-integration/caelestia-vscode-integration-*.vsix
    end
end

log 'Done.'