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
git clone https://github.com/TheK4n/dotfiles
cd dotfiles
make
./install.sh
```

101
install.sh Normal file → Executable file
View File

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