migrate from Makefile to bash installation script

This commit is contained in:
TheK4n 2023-02-28 18:36:39 +03:00
parent 70513a44c9
commit 211ac032f4
2 changed files with 95 additions and 74 deletions

View File

@ -90,7 +90,7 @@ echo "Hello $USER!"
```bash ```bash
git clone https://github.com/TheK4n/dotfiles git clone https://github.com/TheK4n/dotfiles
cd dotfiles cd dotfiles
make ./install.sh
``` ```

101
install.sh Normal file → Executable file
View File

@ -1,3 +1,6 @@
#!/bin/bash
SUB="$(pwd)/sub" SUB="$(pwd)/sub"
@ -26,15 +29,15 @@ cmd_backup() {
} }
cmd_bash() { cmd_bash() {
_die_if_installed "~/.subbash" local subbash="$HOME/.subbash"
_die_if_installed "$subbash"
ln -s "$SUB"/bash ~/.subbash ln -s "$SUB"/bash "$subbash"
ln -s ~/.subbash/bashrc ~/.bashrc ln -s "$subbash"/bashrc ~/.bashrc
} }
cmd_zsh() { cmd_zsh() {
local subzsh local subzsh="$HOME/.subzsh"
subzsh="$HOME/.subzsh"
_die_if_installed "$subzsh" _die_if_installed "$subzsh"
ln -s "$SUB"/zsh "$subzsh" ln -s "$SUB"/zsh "$subzsh"
@ -52,30 +55,20 @@ cmd_tmux() {
} }
cmd_alacritty() { cmd_alacritty() {
_die_if_installed "~/.config/alacritty" local subalacritty="$HOME/.config/alacritty"
_die_if_installed "$subalacritty"
mkdir -p ~/.config/alacritty mkdir -p "$subalacritty"
ln -s "$SUB"/alacritty/alacritty.yml ~/.config/alacritty/ ln -s "$SUB"/alacritty/alacritty.yml "$subalacritty"
} }
cmd_vim() { cmd_nvim() {
echo "sudo pacman -S npm ctags fzf glow; mkdir ~/.npm-global; npm config set prefix '~/.npm-global'; npm install -g pyright" echo "sudo pacman -S npm ctags fzf glow; mkdir ~/.npm-global; npm config set prefix '~/.npm-global'"
local subvim ln -s "$SUB/nvim" "$HOME/.config/nvim"
subvim="$HOME/.vim" ln -s "$(dirname "$SUB")/functions/vim_askpass_helper" "$HOME/.local/bin"
git clone --depth 1 https://github.com/wbthomason/packer.nvim "$HOME/.local/share/nvim/site/pack/packer/start/packer.nvim"
_die_if_installed "$subvim" nvim +PackerCompile +PackerSync +PackerSync
echo "set editing-mode vi" >> ~/.inputrc
ln -s "$SUB"/vim "$subvim"
ln -s $(PWD)/light/.vimrc ~/.vimrc
mkdir -p ~/.config/nvim/lua
ln -s "$subvim"/vimrc ~/.config/nvim/init.vim
ln -s "$SUB"/vim/init.lua ~/.config/nvim/lua/init.lua
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
nvim +PluginInstall +qall
} }
cmd_ssh() { cmd_ssh() {
@ -91,8 +84,7 @@ cmd_git() {
cmd_ranger() { cmd_ranger() {
echo "sudo pacman -S highlight ttf-joypixels noto-fonts-emoji ueberzug poppler" echo "sudo pacman -S highlight ttf-joypixels noto-fonts-emoji ueberzug poppler"
local subranger local subranger="$HOME/.config/ranger"
subranger="$HOME/.config/ranger"
_die_if_installed "$subranger" _die_if_installed "$subranger"
@ -104,8 +96,7 @@ cmd_ranger() {
} }
cmd_gpg() { cmd_gpg() {
local subgpg local subgpg="$HOME/.gnupg"
subgpg="$HOME/.gnupg"
_die_if_installed "$subgpg" _die_if_installed "$subgpg"
@ -117,9 +108,7 @@ cmd_gpg() {
cmd_i3() { cmd_i3() {
echo "sudo pacman -S nitrogen picom compton ttf-font-awesome xdotool xclip maim" echo "sudo pacman -S nitrogen picom compton ttf-font-awesome xdotool xclip maim"
local subi3 subi3status local subi3="$HOME/.config/i3" subi3status="$HOME/.config/i3status"
subi3="$HOME/.config/i3"
subi3status="$HOME/.config/i3status"
_die_if_installed "$subi3" _die_if_installed "$subi3"
_die_if_installed "$subi3status" _die_if_installed "$subi3status"
@ -130,8 +119,7 @@ cmd_i3() {
} }
cmd_bat() { cmd_bat() {
local subbat local subbat="$HOME/.config/bat"
subbat="$HOME/.config/bat"
_die_if_installed "$subbat" _die_if_installed "$subbat"
@ -140,8 +128,7 @@ cmd_bat() {
} }
cmd_ipython() { cmd_ipython() {
local subipython local subipython="$HOME/.ipython"
subipython="$HOME/.ipython"
_die_if_installed "$subipython" _die_if_installed "$subipython"
@ -150,8 +137,7 @@ cmd_ipython() {
} }
cmd_font() { cmd_font() {
local subfont local subfont="$HOME/.local/share/fonts"
subfont="$HOME/.local/share/fonts"
mkdir -p "$subfont" mkdir -p "$subfont"
cd "$subfont" cd "$subfont"
@ -170,12 +156,17 @@ cmd_arch() {
echo 'echo "ParallelDownloads = 5" >> /etc/pacman.conf' echo 'echo "ParallelDownloads = 5" >> /etc/pacman.conf'
} }
cmd_psql() {
ln -s "$SUB/psql/psqlrc" "$HOME/.psqlrc"
}
cmd_unlink() { cmd_unlink() {
##################################################### #####################################################
return 0
} }
cmd_install_functions() { cmd_install_functions() {
for func in $(find functions -type f -maxdepth 1) for func in $(find functions -maxdepth 1 -type f)
do do
chmod 755 "$func" chmod 755 "$func"
ln -s "$func" "$HOME/.local/bin" ln -s "$func" "$HOME/.local/bin"
@ -188,7 +179,7 @@ cmd_install() {
zsh) shift; cmd_zsh "$@" ;; zsh) shift; cmd_zsh "$@" ;;
tmux) shift; cmd_tmux "$@" ;; tmux) shift; cmd_tmux "$@" ;;
alacritty) shift; cmd_alacritty "$@" ;; alacritty) shift; cmd_alacritty "$@" ;;
vim) shift; cmd_vim "$@" ;; nvim) shift; cmd_nvim "$@" ;;
ssh) shift; cmd_ssh "$@" ;; ssh) shift; cmd_ssh "$@" ;;
git) shift; cmd_git "$@" ;; git) shift; cmd_git "$@" ;;
ranger) shift; cmd_ranger "$@" ;; ranger) shift; cmd_ranger "$@" ;;
@ -198,13 +189,43 @@ cmd_install() {
font) shift; cmd_font "$@" ;; font) shift; cmd_font "$@" ;;
termux) shift; cmd_termux "$@" ;; termux) shift; cmd_termux "$@" ;;
arch) shift; cmd_arch "$@" ;; arch) shift; cmd_arch "$@" ;;
psql) shift; cmd_psql "$@" ;;
esac esac
} }
cmd_help() {
echo "Dotfiles installation script:
Usage: ./install.sh install (target)
Usage: ./install.sh unlink (target)
Usage: ./install.sh install-functions
targets:
- bash
- zsh
- tmux
- alacritty
- nvim
- ssh
- git
- ranger
- gpg
- i3
- bat
- font
- termux
- arch
- psql
"
}
case "$1" in case "$1" in
help) shift; cmd_help "$@" ;;
install) shift; cmd_install "$@" ;; install) shift; cmd_install "$@" ;;
unlink) shift; cmd_unlink "$@" ;; unlink) shift; cmd_unlink "$@" ;;
install-functions) shift; cmd_install_functions "$@" ;;
esac esac
exit 0 exit 0