-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·96 lines (81 loc) · 3.76 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env bash
# ██████╗ ██████╗ ████████╗███████╗██╗██╗ ███████╗███████╗
# ██╔══██╗██╔═══██╗╚══██╔══╝██╔════╝██║██║ ██╔════╝██╔════╝
# ██║ ██║██║ ██║ ██║ █████╗ ██║██║ █████╗ ███████╗
# ██║ ██║██║ ██║ ██║ ██╔══╝ ██║██║ ██╔══╝ ╚════██║
# ██████╔╝╚██████╔╝ ██║ ██║ ██║███████╗███████╗███████║
# ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝
# Change directory
SCRIPT_DIR=$(dirname -- "$( readlink -f -- "$0"; )") && cd "$SCRIPT_DIR" || exit
# Gentle reminder
printf "This script will delete already present config files. Continue? (yes/no): " && read -r deletion_choice
case $deletion_choice in
n|no|No|NO|N)
exit 1 ;;
esac
# Install stow if not already present in system
if ! command -v stow > /dev/null; then
./scripts/install-stow.sh
fi
# Remove already existing files & folders
xargs -a "./components/files-and-folders-to-remove.txt" -I {} sh -c 'eval "rm -rf {}"'
# Actual setup of dotfiles
cd .. || exit
stow --adopt -vt ~ "$(basename "$SCRIPT_DIR")" --dotfiles --ignore='install.sh|scripts|components'
# Restore files if they were moved
git --git-dir="$SCRIPT_DIR/.git/" --work-tree="$SCRIPT_DIR" restore .
# Move shell history files if they are present
if [ -f ~/.bash_history ]; then
if [ -f ~/.local/share/bash/bash_history ]; then
cat ~/.bash_history >> ~/.local/share/bash/bash_history
rm ~/.bash_history
else
mv ~/.bash_history ~/.local/share/bash/bash_history
fi
fi
if [ -f ~/.zsh_history ]; then
if [ -f ~/.local/share/zsh/zsh_history ]; then
cat ~/.zsh_history >> ~/.local/share/zsh/zsh_history
rm ~/.zsh_history
else
mv ~/.zsh_history ~/.local/share/zsh/zsh_history
fi
fi
# Create zsh_history if not present
touch ~/.local/share/zsh/zsh_history
# Post-installation things
case "$(sh -c 'ps -p $$ -o ppid=' | xargs ps -o comm= -p)" in
bash)
source ~/.bashrc ;;
fish)
source ~/.config/fish/config.fish ;;
zsh)
source ~/.config/zsh/.zshrc ;;
esac
# Declutter HOME directory
printf "Do you want to declutter your home folder by removing some files? (yes/no): " && read -r declutter_choice
case $declutter_choice in
y|yes|Yes|YES)
xargs -a "$SCRIPT_DIR/components/declutter.txt" -I {} sh -c 'eval "rm -f {}"'
esac
# Disable creation of ~/.Xauthority file
if [ -f ~/.Xauthority ]; then
if command -v bash > /dev/null && [ -f /etc/bash.bashrc ] && ! grep -q 'XDG_RUNTIME' /etc/bash.bashrc; then # Disable using bash
printf "\n# Prevent creation of .Xauthority\
\nexport XAUTHORITY=\$XDG_RUNTIME_DIR/Xauthority\
\n" | sudo tee -a /etc/bash.bashrc
fi
# Store zshenv path into a variable
zshenv_path=$(sudo find /etc -maxdepth 2 -type f -name "zshenv")
if command -v zsh > /dev/null && ! grep -q 'XDG_RUNTIME' "$zshenv_path"; then # Disable using zsh
printf "\n# Prevent creation of .Xauthority\
\nexport XAUTHORITY=\$XDG_RUNTIME_DIR/Xauthority\
\n" | sudo tee -a "$zshenv_path"
fi
mv ~/.Xauthority "$XDG_RUNTIME_DIR"/Xauthority
fi
# Set gnome monospace font to my custom Nerd Font Noto Sans
fc-cache -f
if fc-list | grep -q 'NotoSansM Nerd Font' && command -v dconf > /dev/null; then
dconf write /org/gnome/desktop/interface/monospace-font-name "'NotoSansM Nerd Font 11'"
fi