#!/bin/sh # zprofile isn't installed yet on new machine # shellcheck source=/dev/null . config/zsh/.zshenv if [ "$USER" = 'root' ] then crontab crontab/root.crontab pkgfile --update exit fi parallel_pids='' parallel_start() { "$@" & parallel_pids="$parallel_pids $!" } parallel_wait() { echo 'Waiting for processes' # shellcheck disable=SC2086 wait $parallel_pids parallel_pids='' } mkdir -pv "$XDG_CONFIG_HOME" mkdir -pv "$XDG_DATA_HOME" mkdir -pv "$XDG_CACHE_HOME" # xmonad uses ~/.xmonad if those directories don't already exists if [ "$(uname)" = Linux ] then mkdir -pv "$XMONAD_CONFIG_HOME" mkdir -pv "$XMONAD_DATA_HOME" mkdir -pv "$XMONAD_CACHE_HOME" fi echo '---------------------------- CONFIG FILE LINKS ---------------------------' link_home_files() { rice_dir="$1" dest_dir="$2" paths=$(mktemp) platform="$(uname | tr '[:upper:]' '[:lower:]')" other_platform="$([ "$platform" = 'linux' ] && echo darwin || echo linux)" # generate a file with the file path in this repo and the link for the real path # each line is in the format: TARGET LINKNAME find "$rice_dir" -type f | sed "/\.$other_platform/ d" | sed -e 'p' -e "s:^$rice_dir:$dest_dir:" -e "s/\.$platform//" | awk '{ if (NR % 2 == 1) { print "'"$(pwd)"'" "/" $0 } else print }' | xargs -L 2 > "$paths" < "$paths" cut -d ' ' -f 2 | xargs -L 1 dirname | xargs -L 1 mkdir -pv < "$paths" xargs -L 1 ln -svf } link_home_files 'config' "$XDG_CONFIG_HOME" link_home_files 'local' "$HOME/.local" # ln -svf "$(pwd)/config/zsh/zprofile" "$HOME/.zprofile" ################################################################################ # vim plug ################################################################################ echo '---------------------------- INSTALL VIM PLUG ----------------------------' PLUGFILE="$XDG_DATA_HOME/vim/autoload/plug.vim" PLUGURL='https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' [ ! -f "$PLUGFILE" ] && curl -fLo "$PLUGFILE" --create-dirs "$PLUGURL" vim -c 'PlugInstall' -c 'qa' echo '---------------------------- INSTALL NVIM PACKER -------------------------' PACKERDIR="$XDG_DATA_HOME/nvim/site/pack/packer/start/packer.nvim" PACKERURL='https://github.com/wbthomason/packer.nvim' [ ! -d "$PACKERDIR" ] && git clone --depth 1 "$PACKERURL" "$PACKERDIR" nvim -c 'PackerInstall' -c 'PackerSync' -c "qa" ############################################################################### # zsh pluggins ############################################################################### echo '---------------------------- INSTALL ZSH PLUGGINS ------------------------' update_zsh_plugin() { url="$1" path="$XDG_DATA_HOME/zsh/$(basename "$url")" if [ ! -d "$path" ] || [ -z "$(ls -A "$path")" ] then git clone "$url" "$path" else git -C "$path" pull fi } mkdir -p "$XDG_DATA_HOME/zsh" parallel_start update_zsh_plugin 'https://github.com/sindresorhus/pure' parallel_start update_zsh_plugin 'https://github.com/zsh-users/zsh-syntax-highlighting' parallel_start update_zsh_plugin 'https://github.com/MichaelAquilina/zsh-you-should-use' parallel_wait if [ "$(uname)" = Darwin ] then # xdg vars not defined for qutebrowser ln -svfF "$XDG_CONFIG_HOME/qutebrowser" "$HOME/.qutebrowser" exit fi ############################################################################### # fish pluggins ############################################################################### echo '---------------------------- INSTALL FISH PLUGGINS -----------------------' fish -c 'fisher install pure-fish/pure' fish -c 'fisher install PatrickF1/fzf.fish' fish -c 'fisher install decors/fish-colored-man' fish -c 'fisher install ainmosni/fish-aws' if command -v ya > /dev/null then ya pack -a bennyyip/gruvbox-dark ya pack -a yazi-rs/plugins:git fi ############################################################################### # Linux specific ############################################################################### ############################################################################### # crontab ############################################################################### echo '---------------------------- INSTALL CRONTAB -----------------------------' if [ "$(cat /etc/hostname)" = 'charleslaptopcarbon' ] then cat crontab/user.crontab crontab/laptop.crontab | crontab - elif [ "$(cat /etc/hostname)" = 'cacharle-main' ] then crontab crontab/user.crontab fi echo 'INFO: Run this script as root if you want to install the root contab' ############################################################################### # dictionaries ############################################################################### # command is sdcv echo '---------------------------- INSTALL DICTIONARY --------------------------' install_dict() { url="$1" archive_name="$(basename "$url")" dir_name="${archive_name%%.tar.bz2}" install_dir="${STARDICT_DATA_DIR:-/usr/share/stardict}/dic" [ ! -d "$install_dir" ] && mkdir -pv "$install_dir" [ -d "$install_dir/$dir_name" ] && return echo "----------------------------- Installing dictionary: $dir_name" curl "$url" | tar -xjvf - -C "$install_dir" & } # other dictionaries at: http://download.huzheng.org/ #parallel_start install_dict 'http://download.huzheng.org/dict.org/stardict-dictd_www.dict.org_gcide-2.4.2.tar.bz2' # english #parallel_start install_dict 'http://download.huzheng.org/fr/stardict-xmlittre-2.4.2.tar.bz2' # french #parallel_wait