mirror of
https://github.com/mentos1386/dotfiles.git
synced 2024-11-22 07:33:33 +00:00
refactor: add back switch
This commit is contained in:
parent
a6ad8a52d9
commit
d22cc72ee4
4 changed files with 61 additions and 49 deletions
|
@ -1,2 +1,2 @@
|
||||||
--italic-text='always'
|
--italic-text='always'
|
||||||
--theme=OneHalfDark
|
--theme=OneHalfLight
|
||||||
|
|
47
common.sh
Normal file
47
common.sh
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
REPO_DIR=$(dirname $(readlink -f $0))
|
||||||
|
HOME_DIR=${HOME}
|
||||||
|
OS_RELEASE=$(cat /etc/os-release | grep -E "^ID=" | cut -d= -f2)
|
||||||
|
|
||||||
|
echo_header() {
|
||||||
|
bold=$(tput bold)
|
||||||
|
normal=$(tput sgr0)
|
||||||
|
red=$(tput setaf 1)
|
||||||
|
echo "${bold}${red}$1${normal}"
|
||||||
|
}
|
||||||
|
|
||||||
|
workspace_link() {
|
||||||
|
mkdir -p $(dirname $HOME_DIR/$2)
|
||||||
|
rm $HOME_DIR/$2 || true
|
||||||
|
ln -s $REPO_DIR/$1 $HOME_DIR/$2 || true
|
||||||
|
}
|
||||||
|
|
||||||
|
GUI=NO
|
||||||
|
ENVIRONMENT=personal
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
--env)
|
||||||
|
ENVIRONMENT=$2
|
||||||
|
if [ "$ENVIRONMENT" != "personal" ] && [ "$ENVIRONMENT" != "work" ]; then
|
||||||
|
echo "Unknown environment $ENVIRONMENT"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
shift # past argument
|
||||||
|
shift # past value
|
||||||
|
;;
|
||||||
|
--gui)
|
||||||
|
GUI=YES
|
||||||
|
shift # past argument
|
||||||
|
;;
|
||||||
|
-h | --help)
|
||||||
|
echo "Usage: install.sh [--gui]"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
-* | --*)
|
||||||
|
echo "Unknown option $1"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
echo_header "== DotFiles with GUI: $GUI and ENV: $ENVIRONMENT"
|
52
install.sh
52
install.sh
|
@ -1,51 +1,7 @@
|
||||||
#!/bin/env bash
|
#!/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
REPO_DIR=$(dirname $(readlink -f $0))
|
source common.sh
|
||||||
HOME_DIR=${HOME}
|
|
||||||
OS_RELEASE=$(cat /etc/os-release | grep -E "^ID=" | cut -d= -f2)
|
|
||||||
|
|
||||||
echo_header() {
|
|
||||||
bold=$(tput bold)
|
|
||||||
normal=$(tput sgr0)
|
|
||||||
red=$(tput setaf 1)
|
|
||||||
echo "${bold}${red}$1${normal}"
|
|
||||||
}
|
|
||||||
|
|
||||||
workspace_link() {
|
|
||||||
mkdir -p $(dirname $HOME_DIR/$2)
|
|
||||||
rm $HOME_DIR/$2 || true
|
|
||||||
ln -s $REPO_DIR/$1 $HOME_DIR/$2 || true
|
|
||||||
}
|
|
||||||
|
|
||||||
GUI=NO
|
|
||||||
ENVIRONMENT=personal
|
|
||||||
while [[ $# -gt 0 ]]; do
|
|
||||||
case $1 in
|
|
||||||
--env)
|
|
||||||
ENVIRONMENT=$2
|
|
||||||
if [ "$ENVIRONMENT" != "personal" ] && [ "$ENVIRONMENT" != "work" ]; then
|
|
||||||
echo "Unknown environment $ENVIRONMENT"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
shift # past argument
|
|
||||||
shift # past value
|
|
||||||
;;
|
|
||||||
--gui)
|
|
||||||
GUI=YES
|
|
||||||
shift # past argument
|
|
||||||
;;
|
|
||||||
-h | --help)
|
|
||||||
echo "Usage: install.sh [--gui]"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
-* | --*)
|
|
||||||
echo "Unknown option $1"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
echo_header "== DotFiles with GUI: $GUI and ENV: $ENVIRONMENT"
|
|
||||||
|
|
||||||
# Install basic packages.
|
# Install basic packages.
|
||||||
# Most other packages are installed via Home Manager.
|
# Most other packages are installed via Home Manager.
|
||||||
|
@ -159,6 +115,6 @@ sudo chsh $USER --shell=/bin/zsh
|
||||||
echo_header "==[host] Plug for neovim"
|
echo_header "==[host] Plug for neovim"
|
||||||
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
|
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
|
||||||
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
|
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
|
||||||
nvim --headless +PlugInstall +qa
|
nvim --headless +PlugInstall +qa || true
|
||||||
nvim --headless +PlugUpdate +qa
|
nvim --headless +PlugUpdate +qa || true
|
||||||
nvim --headless +PlugUpgrade +qa
|
nvim --headless +PlugUpgrade +qa || true
|
||||||
|
|
|
@ -1 +1,10 @@
|
||||||
#!/bin/env bash
|
#!/bin/env bash
|
||||||
|
|
||||||
|
source common.sh
|
||||||
|
|
||||||
|
echo_header "==[host] Installing Home Manager packages"
|
||||||
|
workspace_link nix/home.nix .config/home-manager/home.nix
|
||||||
|
workspace_link nix/core.nix .config/home-manager/core.nix
|
||||||
|
workspace_link nix/personal.nix .config/home-manager/personal.nix
|
||||||
|
workspace_link nix/work.nix .config/home-manager/work.nix
|
||||||
|
NIXPKGS_ALLOW_UNFREE=1 ENVIRONMENT=$ENVIRONMENT home-manager switch
|
||||||
|
|
Loading…
Reference in a new issue