Compare commits
2 Commits
03cd4109fd
...
4cc4f2347e
| Author | SHA1 | Date | |
|---|---|---|---|
| 4cc4f2347e | |||
| ebdd73bb31 |
@@ -7,7 +7,7 @@ alias h='history'
|
|||||||
alias grep='grep --color=auto'
|
alias grep='grep --color=auto'
|
||||||
alias d='docker'
|
alias d='docker'
|
||||||
alias dc='docker compose'
|
alias dc='docker compose'
|
||||||
alias dotpull='echo "🔄 Updating dotfiles..." && git -C ~/.dotfiles pull && echo "✅ Done."'
|
alias dotpull='echo "🔄 Updating dotfiles..." && git -C ~/.dotfiles pull && echo "🔗 Re-stowing dotfiles..." && (cd ~ && stow -R .dotfiles) && echo "✅ Done."'
|
||||||
|
|
||||||
alias reloadbash='source ~/.bashrc && echo "Bash config reloaded."'
|
alias reloadbash='source ~/.bashrc && echo "Bash config reloaded."'
|
||||||
|
|
||||||
|
|||||||
39
install.sh
39
install.sh
@@ -4,12 +4,14 @@ set -euo pipefail
|
|||||||
DOTFILES_REPO="https://gitea.purpleraft.com/ryan/dotfiles"
|
DOTFILES_REPO="https://gitea.purpleraft.com/ryan/dotfiles"
|
||||||
DOTFILES_DIR="$HOME/.dotfiles"
|
DOTFILES_DIR="$HOME/.dotfiles"
|
||||||
|
|
||||||
declare -A FILES_TO_LINK=(
|
# Check if stow is installed
|
||||||
[".bashrc"]="$HOME/.bashrc"
|
if ! command -v stow &> /dev/null; then
|
||||||
[".bash_aliases"]="$HOME/.bash_aliases"
|
echo "❌ GNU Stow is not installed. Please install it first:"
|
||||||
[".inputrc"]="$HOME/.inputrc"
|
echo " Ubuntu/Debian: sudo apt install stow"
|
||||||
[".gitconfig"]="$HOME/.gitconfig"
|
echo " macOS: brew install stow"
|
||||||
)
|
echo " Or use the alias: install_stow"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Clone or update the repo
|
# Clone or update the repo
|
||||||
if [ -d "$DOTFILES_DIR/.git" ]; then
|
if [ -d "$DOTFILES_DIR/.git" ]; then
|
||||||
@@ -20,24 +22,21 @@ else
|
|||||||
git clone "$DOTFILES_REPO" "$DOTFILES_DIR"
|
git clone "$DOTFILES_REPO" "$DOTFILES_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Symlink each file safely
|
# Change to parent directory of dotfiles for stow to work correctly
|
||||||
for file in "${!FILES_TO_LINK[@]}"; do
|
cd "$HOME"
|
||||||
target="${FILES_TO_LINK[$file]}"
|
|
||||||
source="$DOTFILES_DIR/$file"
|
|
||||||
|
|
||||||
if [ -L "$target" ]; then
|
# Backup existing files that would conflict with stow
|
||||||
echo "✔ Symlink already exists: $target"
|
for file in .bashrc .bash_aliases .inputrc .gitconfig; do
|
||||||
elif [ -e "$target" ]; then
|
if [ -f "$HOME/$file" ] && [ ! -L "$HOME/$file" ]; then
|
||||||
echo "⚠️ Backing up existing file: $target -> ${target}.bak"
|
echo "⚠️ Backing up existing file: $HOME/$file -> $HOME/${file}.bak"
|
||||||
mv "$target" "${target}.bak"
|
mv "$HOME/$file" "$HOME/${file}.bak"
|
||||||
ln -s "$source" "$target"
|
|
||||||
echo "🔗 Linked: $source → $target"
|
|
||||||
else
|
|
||||||
ln -s "$source" "$target"
|
|
||||||
echo "🔗 Linked: $source → $target"
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Use stow to create symlinks
|
||||||
|
echo "🔗 Using Stow to symlink dotfiles..."
|
||||||
|
stow -d "$HOME" -t "$HOME" .dotfiles
|
||||||
|
|
||||||
# Optionally source the new bashrc
|
# Optionally source the new bashrc
|
||||||
if [[ $- == *i* ]]; then
|
if [[ $- == *i* ]]; then
|
||||||
echo "Reloading Bash config..."
|
echo "Reloading Bash config..."
|
||||||
|
|||||||
Reference in New Issue
Block a user