From cf075eb3ccb9f9934e647f95e2d15cf192d75767 Mon Sep 17 00:00:00 2001 From: Vasili Svirydau Date: Fri, 16 Apr 2021 13:43:22 -0700 Subject: [PATCH] . --- bash.d/20-asdf-vm.sh | 6 +++ bash.d/{10-prompt.sh => 90-prompt.sh} | 0 dotfiles/.config/starship.toml | 2 + setup.d/00-bash.sh | 13 +++++ setup.d/10-starship.sh | 2 +- setup.d/20-asdf-vm.sh | 8 ++++ setup.sh | 68 +++++++++++++++------------ 7 files changed, 67 insertions(+), 32 deletions(-) create mode 100644 bash.d/20-asdf-vm.sh rename bash.d/{10-prompt.sh => 90-prompt.sh} (100%) create mode 100644 dotfiles/.config/starship.toml create mode 100644 setup.d/00-bash.sh create mode 100644 setup.d/20-asdf-vm.sh diff --git a/bash.d/20-asdf-vm.sh b/bash.d/20-asdf-vm.sh new file mode 100644 index 0000000..fbcee90 --- /dev/null +++ b/bash.d/20-asdf-vm.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +if test -d ~/.asdf; then + source $HOME/.asdf/asdf.sh + source $HOME/.asdf/completions/asdf.bash +fi diff --git a/bash.d/10-prompt.sh b/bash.d/90-prompt.sh similarity index 100% rename from bash.d/10-prompt.sh rename to bash.d/90-prompt.sh diff --git a/dotfiles/.config/starship.toml b/dotfiles/.config/starship.toml new file mode 100644 index 0000000..a7b0206 --- /dev/null +++ b/dotfiles/.config/starship.toml @@ -0,0 +1,2 @@ +[elixir] +disabled=true diff --git a/setup.d/00-bash.sh b/setup.d/00-bash.sh new file mode 100644 index 0000000..296c414 --- /dev/null +++ b/setup.d/00-bash.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +if [[ $SHELL =~ "bash" ]]; then + SIGIL="# Managed by dotfiles" + + if ! grep "$SIGIL" ~/.bashrc > /dev/null; then + ( + echo "$SIGIL" + echo "for f in $DOTFILES/bash.d/*.sh; do source \"\$f\"; done" + echo "unset f" + ) >> ~/.bashrc + fi +fi diff --git a/setup.d/10-starship.sh b/setup.d/10-starship.sh index 0616056..3abb2e6 100755 --- a/setup.d/10-starship.sh +++ b/setup.d/10-starship.sh @@ -1,7 +1,7 @@ #!/bin/bash if ! test -x /usr/local/bin/starship; then - curl -fsSL https://starship.rs/install.sh | bash + curl -fsSL https://starship.rs/install.sh | bash fi if ! grep starship ~/.bashrc > /dev/null; then diff --git a/setup.d/20-asdf-vm.sh b/setup.d/20-asdf-vm.sh new file mode 100644 index 0000000..31954d3 --- /dev/null +++ b/setup.d/20-asdf-vm.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if ! test -d ~/.asdf; then + echo "Cloning asdf-vm" + git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.0 +fi + + diff --git a/setup.sh b/setup.sh index 8534e91..73f0cae 100755 --- a/setup.sh +++ b/setup.sh @@ -9,41 +9,47 @@ function finish { trap finish EXIT +function overlay { + local source="$1" + local prefix="$2" + + cd "$source" || exit; + + find . -maxdepth 1 -type f -printf "%f\0" | while IFS= read -r -d $'\0' P; do + local target="${prefix}/${P}" + local backup="${prefix}/${P}.orig.${timestamp}" + # echo "$PWD/$P" "->" "$target" + + # skip existing links + if [ -h "$target" ]; then continue; fi + + + # move existing dir out of the way + if [ -e "$target" ]; then + if [ -e "$backup" ]; then + echo "want to override $target but backup exists" + continue; + fi + + echo -n "Backup ${P}" + mv -v "$target" "$backup" + fi + + # create link + ln -v -s "$PWD/$P" "$target" + + # ensure permissions + chmod -R o-rwx,g-rwx "$target" + done + +} + # From aaronjensen/dotfiles DOTFILES=$( cd "$(dirname "${BASH_SOURCE[0]}")" && pwd || return) -cd "$DOTFILES/dotfiles" || exit; - -find . -maxdepth 1 -type f -printf "%f\0" | while IFS= read -r -d $'\0' P; do - target="${HOME}/${P}" - backup="${HOME}/${P}.orig.${timestamp}" - - # skip existing links - if [ -h "$target" ]; then continue; fi - - # move existing dir out of the way - if [ -e "$target" ]; then - if [ -e "$backup" ]; then - echo "want to override $target but backup exists" - continue; - fi - - echo -n "Backup ${P}" - mv -v "$target" "$backup" - fi - - # create link - ln -v -s "$PWD/$P" "$target" - - # ensure permissions - chmod -R o-rwx,g-rwx "$target" -done +overlay "$DOTFILES/dotfiles" "$HOME" +overlay "$DOTFILES/dotfiles/.config" "$HOME/.config" # shellcheck source=/dev/null for f in "$DOTFILES/setup.d/"*.sh; do source "$f"; done unset f; - -( - echo "for f in $DOTFILES/bash.d/*.sh; do source \"\$f\"; done" - echo "unset f" -) >> ~/.bashrc