-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·96 lines (72 loc) · 2.65 KB
/
setup.sh
File metadata and controls
executable file
·96 lines (72 loc) · 2.65 KB
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
96
#!/bin/bash
set -e
# Colours
BOLD="\033[1m"
OFF="\033[m"
# Confirm prompt function
confirm() {
read -r -p "${1:-Continue?} [y/N]: " reply
[[ "$reply" =~ ^[Yy]$ ]]
}
# Welcome message
# Had to be done this way because cat does not let me bold text
cat <<EOF
___ ___ _____ ___ ___ _ ___ ___
| \ / _ \_ _| __|_ _| | | __/ __|
| |) | (_) || | | _| | || |__| _|\__ \
|___/ \___/ |_| |_| |___|____|___|___/
Welcome to the dotfiles minimal setup script.
Last updated: 6 December 2025
EOF
echo -e "You **${BOLD}must${OFF}** run this script from your home directory."
echo ""
echo -e "Before running this, you **${BOLD}must${OFF}** install the following packages"
cat <<EOF
and ensure that they available on your path via your preferred
method before proceeding,
- git (required)
- zsh (optional)
- npm (for zsh prompt)
- nodejs (for zsh prompt)
- neovim (optional)
- rust/cargo(optional)
EOF
if ! confirm "Have you installed the dependencies?"; then
echo "Please install them first, then run this script."
exit
fi
echo "Setting up dotfiles..."
if confirm "Install zsh prompt? [zsh/npm required]"; then
echo "Installing spaceship-prompt may require manual setup."
npm install -g spaceship-prompt # for zsh prompt
fi
# dotfiles sync https://github.com/aaqsr/dotfiles.git
# Idea for using git bare repo from:
# https://www.atlassian.com/git/tutorials/dotfiles
echo "Setting dotfiles alias in bashrc and zshrc. If neither apply, fix manually"
echo "alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'" >>"$HOME/.bashrc"
echo "alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'" >>"$HOME/.zshrc"
# set alias for this script too
alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
echo ".dotfiles" >>"$HOME/.gitignore"
git clone --bare https://github.com/aaqsr/dotfiles.git "$HOME/.dotfiles"
mkdir -p .dotfiles-backup
dotfiles checkout
if [ $? = 0 ]; then
echo "Checked out dotfiles."
else
echo "Backing up pre-existing dot files."
dotfiles checkout 2>&1 | grep -E "\s+\." | awk "{'print $1'}" | xargs "-I{}" mv "{}" ".dotfiles-backup/{}"
fi
dotfiles checkout
dotfiles config status.showUntrackedFiles no
cat <<EOF
...Done!
To manage dotfiles in the future, use the \`dotfiles\` alias with
\`git\` commands to, for example,
- dotfiles pull (pull changes)
- dotfiles push (push changes)
- dotfiles add <file> (add file to dotfiles repo)
- dotfiles commit -am <msg> (commit changes to dotfiles)
Bye!!
EOF