diff --git a/readme.md b/readme.md index 0ffa5d8..2577e95 100644 --- a/readme.md +++ b/readme.md @@ -45,13 +45,13 @@ is to prevent a repository full of hidden files. ## Usage -### Link the dotfiles: +### Link the dotfiles (stewing) ```sh stowhome [ [ [...]]] ``` -Where `` is a directory from this repo. +Where `` 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 [ [ [...]]] To overwrite the dotfile, you can just remove or rename the file and then run `stowhome` again. +### Unlink the dotfiles (destewing) + +```sh +stowhome -D [ [ [...]]] +``` + ### Update dotfiles To edit an already managed by stowhome dotfile, you can just edit it. The diff --git a/stow/dot-local/bin/stowhome b/stow/dot-local/bin/stowhome index 63b0928..19cd91d 100755 --- a/stow/dot-local/bin/stowhome +++ b/stow/dot-local/bin/stowhome @@ -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