Skip to content

Commit

Permalink
Run stow with --dotfiles, add --stow-only
Browse files Browse the repository at this point in the history
  • Loading branch information
Jendker committed Oct 1, 2024
1 parent 9b2a3fe commit 66fabe3
Show file tree
Hide file tree
Showing 36 changed files with 80 additions and 45 deletions.
1 change: 0 additions & 1 deletion debian/.config/clangd

This file was deleted.

2 changes: 1 addition & 1 deletion dotfiles_private
1 change: 0 additions & 1 deletion macos/Library/Preferences/clangd

This file was deleted.

94 changes: 64 additions & 30 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,50 @@ ROOT_DIR=$(dirname "$SCRIPT_DIR")

# Initialize flags
dev=false
copy=false
install_only=false
stow_only=false

function install_stow_debian {
if ! [ -x "$(command -v perl)" ]; then
sudo apt install perl -y
fi
current_dir=$(pwd)

cd /tmp
wget https://mirror.fcix.net/gnu/stow/stow-latest.tar.gz

tar -xzf stow-latest.tar.gz

# Find the extracted directory (it should match "stow-X.Y.Z")
dir_name=$(tar -tzf stow-latest.tar.gz | head -1 | cut -f1 -d"/")

# Change into the extracted directory
cd "$dir_name"

./configure && sudo make install

# cleanup
cd /tmp
rm -rf "$dir_name" && rm "stow-latest.tar.gz"
cd "${current_dir}"
}

# Loop through the arguments
for arg in "$@"; do
if [ "$arg" == "--copy" ]; then
copy=true
elif [ "$arg" == "--dev" ]; then
if [ "$arg" == "--dev" ]; then
dev=true
elif [ "$arg" == "--optional" ]; then
dev=true
elif [ "$arg" == "--install-only" ]; then
install_only=true
elif [ "$arg" == "--stow-only" ]; then
stow_only=true
fi
done

copy=false
if [[ $1 == "--copy" ]]; then
copy=true
fi

function add() {
rm -r "$2" || true
if [[ $copy == true ]]; then
cp -r "$1" "$2"
else
ln -s "$1" "$2"
fi
ln -s "$1" "$2"
}

# snippets
Expand All @@ -54,7 +70,16 @@ cd "$ROOT_DIR"

if ! [ -x "$(command -v stow)" ]; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt install stow -y
stow_version=$(stow --version | awk 'NR==1{print $NF}')
min_stow_version="2.4.0"

# Compare versions
if [ "$(printf '%s\n' "$stow_version" "$min_stow_version" | sort -V | head -n1)" = "$stow_version" ] && [ "$stow_version" != "$min_stow_version" ]; then
echo "Your stow version ($stow_version) is lower than $min_stow_version."
echo "Installing from tarfile"
install_stow_debian
fi

elif [[ "$OSTYPE" == "darwin"* ]]; then
if ! [ -x "$(command -v brew)" ]; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Expand All @@ -65,7 +90,7 @@ if ! [ -x "$(command -v stow)" ]; then
fi
fi

# Stow platform-specific config
# Stow platform-specific prefix to run stow
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
prefix="debian"
elif [[ "$OSTYPE" == "darwin"* ]]; then
Expand All @@ -76,33 +101,42 @@ else
fi

if [[ $install_only != true ]]; then
cd stow
# Stow common config
stow -t ~ common
stow -t ~ "${prefix}"
stow --dotfiles -t ~ common
# Stow platform specific stuff
stow --dotfiles -t ~ "${prefix}"

cd ..
fi

# Platform-specific config install
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
"${SCRIPT_DIR}/debian/install_min.sh"
if [[ $dev == true ]]; then
"${SCRIPT_DIR}/debian/install.sh" --optional
if [[ $stow_only != true ]]; then
# Platform-specific config install
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
"${SCRIPT_DIR}/debian/install_min.sh"
if [[ $dev == true ]]; then
"${SCRIPT_DIR}/debian/install.sh" --optional
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
"${SCRIPT_DIR}/macos/install.sh"
else
echo "Unsupported OS"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
"${SCRIPT_DIR}/macos/install.sh"
else
echo "Unsupported OS"
fi

# Private submodule install
SUBMODULE_PATH="dotfiles_private"
# Check if the submodule is not empty
if [[ -n "$(ls -A ${SUBMODULE_PATH})" ]]; then
echo "Private submodule is available. Installing..."
install_only_arg=""
submodule_args=()
if [[ $install_only == true ]]; then
install_only_arg="--install-only"
submodule_args+=("--install-only")
fi
if [[ $stow_only == true ]]; then
submodule_args+=("--stow-only")
fi
"${SUBMODULE_PATH}/scripts/install.sh" $install_only_arg
"${SUBMODULE_PATH}/scripts/install.sh" "${submodule_args[@]}"
else
echo "Private submodule is not cloned. Skipping installation."
fi
11 changes: 6 additions & 5 deletions scripts/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,25 @@ cd "$ROOT_DIR"

# Private submodule uninstall
SUBMODULE_PATH="dotfiles_private"
SUBMODULE_STATUS=$(git submodule status $SUBMODULE_PATH) || (git config --add safe.directory "${ROOT_DIR}" && SUBMODULE_STATUS=$(git submodule status $SUBMODULE_PATH))

# Check if the submodule is not empty
if [[ ! -z "$(ls -A ${SUBMODULE_PATH})" ]]; then
if [[ -n "$(ls -A ${SUBMODULE_PATH})" ]]; then
echo "Private submodule is available. Uninstalling..."
"${SUBMODULE_PATH}/scripts/uninstall.sh"
else
echo "Private submodule is not cloned. Skipping uninstallation."
fi

cd stow

# Unstow platform-specific config
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
stow -D -t ~ debian
stow --dotfiles -D -t ~ debian
elif [[ "$OSTYPE" == "darwin"* ]]; then
stow -D -t ~ macos
stow --dotfiles -D -t ~ macos
else
echo "Unsupported OS"
fi

# Unstow common
stow -D -t ~ common
stow --dotfiles -D -t ~ common
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"CopilotChat.nvim": { "branch": "canary", "commit": "2352cd3e7e980cd73594be05f96b2dc4c0dd4a74" },
"CopilotChat.nvim": { "branch": "canary", "commit": "9333944fde3c65868818e245c73aa29eef826e9b" },
"LuaSnip": { "branch": "master", "commit": "e808bee352d1a6fcf902ca1a71cee76e60e24071" },
"Navigator.nvim": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" },
"aerial.nvim": { "branch": "master", "commit": "140f48fb068d21c02e753c63f7443649e55576f0" },
Expand All @@ -16,7 +16,7 @@
"copilot.lua": { "branch": "master", "commit": "1a237cf50372830a61d92b0adf00d3b23882e0e1" },
"diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
"dressing.nvim": { "branch": "master", "commit": "1b7921eecc65af1baf8ac1dc06f0794934cbcfb2" },
"dropbar.nvim": { "branch": "master", "commit": "b7b0cd2670cfab298afc955f2531206218736766" },
"dropbar.nvim": { "branch": "master", "commit": "a12869f34f8cd236dc708fb2815ccf1663000bf4" },
"flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" },
"friendly-snippets": { "branch": "main", "commit": "00ba9dd3df89509f95437b8d595553707c46d5ea" },
"fugitive-gitlab.vim": { "branch": "master", "commit": "838d3a110836f511be099002ce1a71493c042615" },
Expand All @@ -29,7 +29,7 @@
"incline.nvim": { "branch": "main", "commit": "16fc9c073e3ea4175b66ad94375df6d73fc114c0" },
"indent-blankline.nvim": { "branch": "master", "commit": "18603eb949eba08300799f64027af11ef922283f" },
"kanagawa.nvim": { "branch": "master", "commit": "f491b0fe68fffbece7030181073dfe51f45cda81" },
"last-color.nvim": { "branch": "main", "commit": "4086c5810bbe35b4184502f190e8d1ba910180cd" },
"last-color.nvim": { "branch": "main", "commit": "95d3bb07409a8334ecc57336cc39673ecca02ae0" },
"lazy.nvim": { "branch": "main", "commit": "460e1cd8f24e364d54543a4b0e83f6f4ec1f65fb" },
"lsp-zero.nvim": { "branch": "v4.x", "commit": "b8411704591ae8e1501f1b9b31c801c09927baac" },
"lsp_signature.nvim": { "branch": "master", "commit": "fc38521ea4d9ec8dbd4c2819ba8126cea743943b" },
Expand All @@ -39,7 +39,7 @@
"mason-null-ls.nvim": { "branch": "main", "commit": "de19726de7260c68d94691afb057fa73d3cc53e7" },
"mason-nvim-dap.nvim": { "branch": "main", "commit": "8b9363d83b5d779813cdd2819b8308651cec2a09" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"neoconf.nvim": { "branch": "main", "commit": "c5516054f2342e6fe4d3befd56249d02d5eeb380" },
"neoconf.nvim": { "branch": "main", "commit": "944f30e58171cf909b6567ce206e9097745560d1" },
"neoscroll.nvim": { "branch": "master", "commit": "4e0428a41c6ec191df543fc95349f6e1c598e53f" },
"nvim-autopairs": { "branch": "master", "commit": "f158dcb865c36f72c92358f87787dab2c272eaf3" },
"nvim-bqf": { "branch": "main", "commit": "1b24dc6050c34e8cd377b6b4cd6abe40509e0187" },
Expand All @@ -53,12 +53,12 @@
"nvim-early-retirement": { "branch": "main", "commit": "2c36a5671b9d8f0d9e11b77c5a55de802bc45e34" },
"nvim-fundo": { "branch": "main", "commit": "ac9c9372c4bf677721e24f144ef29d3a05c2b589" },
"nvim-lint": { "branch": "master", "commit": "968a35d54b3a4c1ce66609cf80b14d4ae44fe77f" },
"nvim-lspconfig": { "branch": "master", "commit": "dd329912c8d446240584a2dbcd3802af3a19105a" },
"nvim-lspconfig": { "branch": "master", "commit": "a9bc587e9ae0cbcb3e90a2e9342f86b3b78c4408" },
"nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" },
"nvim-scrollview": { "branch": "main", "commit": "401c0498689dcaa54b2e7483d823e33cdc051e72" },
"nvim-spectre": { "branch": "master", "commit": "ba7fb777edff6c1fbbeffd343e113af64c04e90a" },
"nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" },
"nvim-treesitter": { "branch": "master", "commit": "6511cd984ab4b21e28f83af488f38dc89c3b0586" },
"nvim-treesitter": { "branch": "master", "commit": "679883ad31f1752cac92a4ca182cee8b2751d4f1" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "bf8d2ad35d1d1a687eae6c065c3d524f7ab61b23" },
"nvim-web-devicons": { "branch": "master", "commit": "26220156aafb198b2de6a4cf80c1b120a3768da0" },
"oil.nvim": { "branch": "master", "commit": "1360be5fda9c67338331abfcd80de2afbb395bcd" },
Expand All @@ -70,7 +70,7 @@
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
"promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" },
"quicker.nvim": { "branch": "master", "commit": "183041a46d6c908eefb1c23ea02cce9c8f41256e" },
"render-markdown.nvim": { "branch": "main", "commit": "67288febca78b7aac8fae9543ef8980237e27d2a" },
"render-markdown.nvim": { "branch": "main", "commit": "629b5f7dc053b73cd753e4ceb830a45f86f9b3da" },
"spaceless.nvim": { "branch": "main", "commit": "8d46bc098dba18d4e19bce89bf19aab5007ef767" },
"stickybuf.nvim": { "branch": "master", "commit": "183b9569bef78f44b17c078214f7d731f19cbefe" },
"substitute.nvim": { "branch": "main", "commit": "17ffaeb5a1dc2dbef39cf0865d8a4b6000836714" },
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions stow/debian/dot-config/clangd
File renamed without changes.
1 change: 1 addition & 0 deletions stow/macos/Library/Preferences/clangd
File renamed without changes.
File renamed without changes.

0 comments on commit 66fabe3

Please sign in to comment.