stowhome: add all keyword to match all packages

This commit is contained in:
Laila van Reenen 2025-08-16 18:20:31 +02:00
parent f414fef84b
commit 9c041754b7
Signed by: LailaTheElf
GPG Key ID: 8A3EF0226518C12D
2 changed files with 24 additions and 5 deletions

View File

@ -45,13 +45,13 @@ is to prevent a repository full of hidden files.
## Usage
### Link the dotfiles:
### Link the dotfiles (stewing)
```sh
stowhome <package> [<package> [<package> [...]]]
```
Where `<package>` is a directory from this repo.
Where `<package>` is a directory from this repo or `all` foor all packages.
If the dotfiles already exist as normal files (not symlinks), it will skip this
file. To overwrite the file in stow, use this command:
@ -63,6 +63,12 @@ stowhome --adopt <package> [<package> [<package> [...]]]
To overwrite the dotfile, you can just remove or rename the file and then run
`stowhome` again.
### Unlink the dotfiles (destewing)
```sh
stowhome -D <package> [<package> [<package> [...]]]
```
### Update dotfiles
To edit an already managed by stowhome dotfile, you can just edit it. The

View File

@ -1,11 +1,24 @@
#!/bin/bash
function get_all_packages() {
cd "$HOME/.config/dotfiles"
find . -maxdepth 1 -type d -not -name ".git" -not -name "."
}
stow_cmd="stow --dir '$HOME/.config/dotfiles' --target '$HOME' --dotfiles"
if [ "$*" == "" ]
then
echo "you must supply at least one package"
echo
echo "packages:"
cd "$HOME/.config/dotfiles" && find . -maxdepth 1 -type d -not -name ".git" -not -name "." | sed -e 's|^.\/| - |'
echo "available packages:"
get_all_packages | sed -e 's|^.\/| - |'
else
stow --dir "$HOME/.config/dotfiles" --target "$HOME" --dotfiles $*
if [ "$(echo "$*" | grep -E -e '^(.* )?all$')" != "" ]
then
all_packages=$(get_all_packages | sed -e 's|^.\/||' | tr '\n' ' ')
$stow_cmd $(echo "$*" | sed -e "s/all/$all_packages/")
else
$stow_cmd $*
fi
fi