From 75f0f6ade837915a6ffd6c4c2859aab6ce6d720c Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 6 Jun 2026 18:09:43 +0200 Subject: *.sh -> scripts/ --- scripts/setup.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ scripts/vim_plugins.sh | 37 +++++++++++++++++++++++++++ setup.sh | 68 -------------------------------------------------- vim_plugins.sh | 37 --------------------------- 4 files changed, 105 insertions(+), 105 deletions(-) create mode 100755 scripts/setup.sh create mode 100755 scripts/vim_plugins.sh delete mode 100755 setup.sh delete mode 100755 vim_plugins.sh diff --git a/scripts/setup.sh b/scripts/setup.sh new file mode 100755 index 0000000..a7f9972 --- /dev/null +++ b/scripts/setup.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +set -o errexit -o nounset -o pipefail +shopt -s inherit_errexit 2> /dev/null || true +shopt -s lastpipe + +script_dir="$( dirname -- "${BASH_SOURCE[0]}" )" +script_dir="$( cd -- "$script_dir" && pwd )" +readonly script_dir + +repo_dir='' + +cleanup_repo() { + if [ -n "$repo_dir" ]; then + echo "Cleaning up directory: $repo_dir" + rm -rf -- "$repo_dir" + fi +} + +config_links_in_path() { + # Make sure the links-* utils are available. + + if command -v links-update &> /dev/null; then + return 0 + fi + + # This is a common directory to clone config-links for me. + if [ -d "$script_dir/../../config-links" ]; then + export PATH="$script_dir/../../config-links/bin:$PATH" + return 0 + fi + + # If config-links is unavailable, clone it. + readonly repo_url=https://github.com/egor-tensin/config-links.git + trap cleanup_repo EXIT + repo_dir="$( mktemp -d )" + + git clone -- "$repo_url" "$repo_dir" + export PATH="$repo_dir/bin:$PATH" +} + +links_update() { + cd -- "$script_dir/.." + links-update + + # Some utilities (for example, ssh) fix too relaxed file permissions + # automatically. Others (GHCi is the reason this exists) just spit out a + # warning and ignore such files. This script simply removes the write + # permission for everybody except myself for every file in this repository. + links-chmod go-w +} + +post_update() { + # Update the vim plugins: + "$script_dir/vim_plugins.sh" + + # Remove ~/.ssh/known_hosts, I don't use it (and have a corresponding + # setting in ~/.ssh/config): + rm -f -- "$HOME/.ssh/known_hosts" +} + +main() { + config_links_in_path + links_update + post_update +} + +main diff --git a/scripts/vim_plugins.sh b/scripts/vim_plugins.sh new file mode 100755 index 0000000..3801b74 --- /dev/null +++ b/scripts/vim_plugins.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -o errexit -o nounset -o pipefail +shopt -s inherit_errexit 2> /dev/null || true +shopt -s lastpipe + +plugins_dir="$HOME/.vim/pack/plugins/start" +readonly plugins_dir + +plugins=( + altercation/vim-colors-solarized + editorconfig/editorconfig-vim +) + +pull() { + local plugin + for plugin in ${plugins[@]+"${plugins[@]}"}; do + local name + name="${plugin#*/}" + + if [ -d "$name" ]; then + echo "Updating plugin: $plugin" + git -C "$name" pull + else + echo "Installing plugin: $plugin" + git clone -q "https://github.com/$plugin.git" + fi + done +} + +main() { + mkdir -p -- "$plugins_dir" + cd -- "$plugins_dir" + pull +} + +main diff --git a/setup.sh b/setup.sh deleted file mode 100755 index 29038a7..0000000 --- a/setup.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -o nounset -o pipefail -shopt -s inherit_errexit 2> /dev/null || true -shopt -s lastpipe - -script_dir="$( dirname -- "${BASH_SOURCE[0]}" )" -script_dir="$( cd -- "$script_dir" && pwd )" -readonly script_dir - -repo_dir='' - -cleanup_repo() { - if [ -n "$repo_dir" ]; then - echo "Cleaning up directory: $repo_dir" - rm -rf -- "$repo_dir" - fi -} - -config_links_in_path() { - # Make sure the links-* utils are available. - - if command -v links-update &> /dev/null; then - return 0 - fi - - # This is a common directory to clone config-links for me. - if [ -d "$script_dir/../config-links" ]; then - export PATH="$script_dir/../config-links:$PATH" - return 0 - fi - - # If config-links is unavailable, clone it. - readonly repo_url=https://github.com/egor-tensin/config-links.git - trap cleanup_repo EXIT - repo_dir="$( mktemp -d )" - - git clone -q -- "$repo_url" "$repo_dir" - export PATH="$repo_dir:$PATH" -} - -links_update() { - cd -- "$script_dir" - links-update - - # Some utilities (for example, ssh) fix too relaxed file permissions - # automatically. Others (GHCi is the reason this exists) just spit out a - # warning and ignore such files. This script simply removes the write - # permission for everybody except myself for every file in this repository. - links-chmod go-w -} - -post_update() { - # Update the vim plugins: - "$script_dir/vim_plugins.sh" - - # Remove ~/.ssh/known_hosts, I don't use it (and have a corresponding - # setting in ~/.ssh/config): - rm -f -- "$HOME/.ssh/known_hosts" -} - -main() { - config_links_in_path - links_update - post_update -} - -main diff --git a/vim_plugins.sh b/vim_plugins.sh deleted file mode 100755 index 3801b74..0000000 --- a/vim_plugins.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -o nounset -o pipefail -shopt -s inherit_errexit 2> /dev/null || true -shopt -s lastpipe - -plugins_dir="$HOME/.vim/pack/plugins/start" -readonly plugins_dir - -plugins=( - altercation/vim-colors-solarized - editorconfig/editorconfig-vim -) - -pull() { - local plugin - for plugin in ${plugins[@]+"${plugins[@]}"}; do - local name - name="${plugin#*/}" - - if [ -d "$name" ]; then - echo "Updating plugin: $plugin" - git -C "$name" pull - else - echo "Installing plugin: $plugin" - git clone -q "https://github.com/$plugin.git" - fi - done -} - -main() { - mkdir -p -- "$plugins_dir" - cd -- "$plugins_dir" - pull -} - -main -- cgit v1.3