#!/bin/bash

if command -v zsh &> /dev/null; then
    zsh -i -c 'zinit update'
fi
if command -v vim &> /dev/null; then
    vim +PlugInstall  +qall
fi
if command -v nvim &> /dev/null; then
    nvim --headless "+Lazy! update" +qa
fi
if command -v tmux &> /dev/null; then
    ~/.tmux/plugins/tpm/bin/install_plugins
    ~/.tmux/plugins/tpm/bin/update_plugins all
fi

{{ if and (not .noGUI) (hasKey .chezmoi.osRelease "id") }}
{{ if and (eq .chezmoi.os "linux") (stat (print .chezmoi.homeDir "/.winscp")) }}
{{ if or (eq .chezmoi.osRelease.id "manjaro") (eq .chezmoi.osRelease.id "arch") }}
mkdir -p ~/.winscp
mkdir -p ~/.winscp/drive_c/users/{{ .chezmoi.username }}/.ssh
{{ if and (stat (print .chezmoi.homeDir "/.ssh/config")) (not (stat (print .chezmoi.homeDir "/.winscp/drive_c/users/" .chezmoi.username "/.ssh/config"))) }}
ln -s ~/.ssh/config ~/.winscp/drive_c/users/{{ .chezmoi.username }}/.ssh/config
{{ end }}
{{ if and (stat (print .chezmoi.homeDir "/.ssh/known_hosts")) (not (stat (print .chezmoi.homeDir "/.winscp/drive_c/users/" .chezmoi.username "/.ssh/known_hosts"))) }}
ln -s ~/.ssh/known_hosts ~/.winscp/drive_c/users/{{ .chezmoi.username }}/.ssh/known_hosts
{{ end }}
{{ if and (stat (print .chezmoi.homeDir "/.config/filezilla/sitemanager.xml")) (not (stat (print .chezmoi.homeDir "/.winscp/drive_c/users/" .chezmoi.username "/AppData/Roaming/FileZilla/sitemanager.xml"))) }}
mkdir -p ~/.winscp/drive_c/users/{{ .chezmoi.username }}/AppData/Roaming/FileZilla
ln -s ~/.config/filezilla/sitemanager.xml ~/.winscp/drive_c/users/{{ .chezmoi.username }}/AppData/Roaming/FileZilla/sitemanager.xml
{{ end }}
{{ end }}
{{ end }}
{{ end }}
