Nicer output messages during cloning + create $DOTFILES/.stow to protect Stow from itself
This commit is contained in:
parent
b4fb45e322
commit
0dd349e924
1 changed files with 13 additions and 7 deletions
|
@ -2,9 +2,11 @@
|
||||||
|
|
||||||
bootstrap() {
|
bootstrap() {
|
||||||
echo 'Bootstrapping your dotfiles...' >&2
|
echo 'Bootstrapping your dotfiles...' >&2
|
||||||
|
mkdir -p $DOTFILES
|
||||||
|
touch $DOTFILES/.stow
|
||||||
if ! hash stow 2>/dev/null; then
|
if ! hash stow 2>/dev/null; then
|
||||||
echo 'GNU Stow is not installed, fetching it...' >&2
|
echo 'GNU Stow is not installed, fetching it...' >&2
|
||||||
clone stow || return $?
|
clone-one stow || return $?
|
||||||
STOW=$DOTFILES/stow/.local/bin/stow
|
STOW=$DOTFILES/stow/.local/bin/stow
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -14,6 +16,7 @@ bootstrap() {
|
||||||
}
|
}
|
||||||
|
|
||||||
clone() {
|
clone() {
|
||||||
|
echo "Requested packages: $argv" >&2
|
||||||
for package in $argv; do
|
for package in $argv; do
|
||||||
clone-one $package || return $?
|
clone-one $package || return $?
|
||||||
done
|
done
|
||||||
|
@ -26,23 +29,26 @@ clone-one() {
|
||||||
[[ $url != */* ]] && url=$GITHUB_USER/dot-$package
|
[[ $url != */* ]] && url=$GITHUB_USER/dot-$package
|
||||||
# user/repo packages are fetched from that user's repos.
|
# user/repo packages are fetched from that user's repos.
|
||||||
[[ $url != *:* ]] && url=https://github.com/$url
|
[[ $url != *:* ]] && url=https://github.com/$url
|
||||||
mkdir -p $DOTFILES
|
if [[ -d $DOTFILES/$package ]]; then
|
||||||
cd $DOTFILES
|
|
||||||
if [[ -d $package ]]; then
|
|
||||||
echo "Looks like you already have $package cloned." >&2
|
echo "Looks like you already have $package cloned." >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
echo "Retrieving $package from $url now..." >&2
|
echo "Retrieving $package from $url now..." >&2
|
||||||
git clone $url $package
|
git clone $url $DOTFILES/$package
|
||||||
}
|
}
|
||||||
|
|
||||||
link() {
|
link() {
|
||||||
local packages=($argv)
|
local packages=($argv)
|
||||||
if (( $#packages == 0 )); then
|
if (( $#packages == 0 )); then
|
||||||
echo 'Packages not given. Assuming all...' >&2
|
|
||||||
packages=( $DOTFILES/*(N:t) )
|
packages=( $DOTFILES/*(N:t) )
|
||||||
|
if (( $#packages == 0 )); then
|
||||||
|
echo "No installed packages! Do you want to clone some first?" >&2
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
|
echo "Linking all packages ($packages) into $HOME now..." >&2
|
||||||
|
else
|
||||||
echo "Linking $packages into $HOME now..." >&2
|
echo "Linking $packages into $HOME now..." >&2
|
||||||
|
fi
|
||||||
$STOW -d $DOTFILES -t ~ $packages
|
$STOW -d $DOTFILES -t ~ $packages
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue