Skip to content

Commit

Permalink
Make scripts quieter and avoid using cargo
Browse files Browse the repository at this point in the history
  • Loading branch information
geodimm committed Mar 19, 2022
1 parent 5ebbc2a commit 540c4c5
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 86 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
include test.mk

.DEFAULT_GOAL := all
.PHONY: git

all: system git languages terminal tools neovim ## Install and configure everything (default)
help: ## Display help
Expand Down
48 changes: 0 additions & 48 deletions colorls/dark_colors.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/bat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
# shellcheck source=../scripts/util.sh
source "$(pwd)/scripts/util.sh"

BAT_VERSION="${BAT_VERSION:=0.19.0}"
BAT_VERSION="${BAT_VERSION:=0.20.0}"

do_install() {
if [[ "$(bat --version 2>/dev/null)" == *"${BAT_VERSION}"* ]]; then
Expand Down
4 changes: 2 additions & 2 deletions scripts/fzf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ FZF_DIR="${HOME}/.fzf"
do_install() {
if is_installed fzf; then
info "[fzf] Already installed. Updating..."
cd "${FZF_DIR}" && git pull && ./install --bin
cd "${FZF_DIR}" && git pull --quiet && ./install --bin
return
fi

info "[fzf] Install"
if [[ ! -d "${FZF_DIR}" ]]; then
git clone --depth 1 https://github.com/junegunn/fzf.git "${FZF_DIR}"
git clone --quiet --depth 1 https://github.com/junegunn/fzf.git "${FZF_DIR}"
"${FZF_DIR}/install" --no-bash --no-fish --key-bindings --completion --no-update-rc
fi
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/gnome-terminal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ do_configure() {
info "[gnome-terminal] Configure"
info "[gnome-terminal][configure] Configure themes"
rm -rf "$install_dir" && mkdir -p "$install_dir"
git clone https://github.com/Mayccoll/Gogh.git "$install_dir"
git clone --quiet https://github.com/Mayccoll/Gogh.git "$install_dir"

info "[gnome-terminal][configure][themes] One Dark"
"$install_dir/themes/one-dark.sh"
Expand Down
13 changes: 10 additions & 3 deletions scripts/lsd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ set -e
# shellcheck source=../scripts/util.sh
source "$(pwd)/scripts/util.sh"

LSD_VERSION="${LSD_VERSION:=0.21.0}"

do_install() {
if [[ "$(lsd --version 2>/dev/null)" == *"${LSD_VERSION}"* ]]; then
info "[lsd] ${LSD_VERSION} already installed"
return
fi

info "[lsd] Install"
# shellcheck source=../../.cargo/env
source "${HOME}/.cargo/env"
cargo install lsd
local lsd=/tmp/lsd.deb
download_to "${lsd}" "https://github.com/Peltoche/lsd/releases/download/${LSD_VERSION}/lsd_${LSD_VERSION}_amd64.deb"
sudo dpkg -i "${lsd}"
}

main() {
Expand Down
4 changes: 2 additions & 2 deletions scripts/lua.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ do_install() {
info "[lua] Install"
local lua="lua-${LUA_VERSION}"
local target="/tmp/${lua}.tar.gz"
download_to "${target}" "http://www.lua.org/ftp/${lua}.tar.gz"
cd /tmp
download_to "${target}" http://www.lua.org/ftp/${lua}.tar.gz
tar -xzf "${target}"
cd "${lua}"
make linux test
Expand All @@ -32,7 +32,7 @@ do_install() {
info "[luarocks] Install"
local luarocks="luarocks-${LUAROCKS_VERSION}"
local target="/tmp/${luarocks}.tar.gz"
download_to "${target}" http://www.luarocks.org/releases/${luarocks}.tar.gz
download_to "${target}" "http://www.luarocks.org/releases/${luarocks}.tar.gz"
cd /tmp
tar -xzf "${target}"
cd "${luarocks}"
Expand Down
11 changes: 6 additions & 5 deletions scripts/neovim-nightly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ source "$(pwd)/scripts/util.sh"

do_install() {
info "[neovim-nightly] Install"
local nvim_path="${HOME}/bin/nvim"
asset=$(curl --silent https://api.github.com/repos/neovim/neovim/releases/tags/nightly | jq -r '.assets // [] | .[] | select(.name | endswith("nvim.appimage")) | .url')
if [[ -z $asset ]]; then
if [[ -z ${asset} ]]; then
warn "Cannot find a nightly release. Please try again later."
exit 0
fi
curl --silent --location -H "Accept: application/octet-stream" "${asset}" >~/bin/nvim
chmod +x ~/bin/nvim
download_to "${asset}" "${nvim_path}"
chmod +x "${nvim_path}"

info "[neovim-nightly][install] Create symlinks to override the stable version"
ln -sf ~/bin/nvim ~/bin/vi
ln -sf ~/bin/nvim ~/bin/vim
ln -sf "${nvim_path}" "${HOME}/bin/vi"
ln -sf "${nvim_path}" "${HOME}/bin/vim"
}

main() {
Expand Down
17 changes: 9 additions & 8 deletions scripts/neovim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,34 @@ do_configure() {
sudo update-alternatives --install /usr/bin/editor editor "$nvim_path" 60
sudo update-alternatives --set editor "$nvim_path"

info "[neovim][configure] Create symlinks"
rm -rf "${XDG_CONFIG_HOME}/nvim"
mkdir -p "${XDG_CONFIG_HOME}"
info "[neovim][configure] Create configuration directory symlink"
rm -rf "${XDG_CONFIG_HOME}/nvim" && mkdir -p "${XDG_CONFIG_HOME}"
ln -fs "$(pwd)/nvim" "${XDG_CONFIG_HOME}/nvim"

info "[neovim][configure] Install the neovim package for languages"
info "[neovim][configure][languages] Python"
python3 -m pip install neovim neovim-remote --user
python3 -m pip install --quiet neovim neovim-remote --user

info "[neovim][configure][languages] Node.js"
# shellcheck source=../../.nvm/nvm.sh
source "${NVM_DIR}/nvm.sh" && npm install -g neovim
source "${NVM_DIR}/nvm.sh" && npm install --quiet -g neovim

info "[neovim][configure] Install dependencies for LSP"
info "[neovim][configure][dependencies] yarn"
# shellcheck source=../../.nvm/nvm.sh
source "${NVM_DIR}/nvm.sh"
npm install -g yarn
npm install --quiet -g yarn

info "[neovim][configure] Install linters for LSP"

info "[neovim][configure][linters] markdownlint-cli"
npm install -g markdownlint-cli
npm install --quiet -g markdownlint-cli

info "[neovim][configure][linters] hadolint"
asset=$(curl --silent "https://api.github.com/repos/hadolint/hadolint/releases/latest" | jq -r '.assets // [] | .[] | select(.name | startswith("hadolint-Linux")) | .url')
curl --silent --location -H "Accept: application/octet-stream" "${asset}" --output "$HOME/bin/hadolint" && chmod +x "$HOME/bin/hadolint"
local hadolint="${HOME}/bin/hadolint"
download_to "${hadolint}" "${asset}"
chmod +x "${hadolint}"

info "[neovim][configure][linters] shfmt"
/usr/local/go/bin/go install mvdan.cc/sh/v3/cmd/shfmt@latest
Expand Down
2 changes: 1 addition & 1 deletion scripts/nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ do_install() {

info "[nvm] Install ${NVM_VERSION}"
mkdir -p "${NVM_DIR}"
curl -o- "https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.sh" | bash
curl --silent -o- "https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.sh" | bash
}

main() {
Expand Down
2 changes: 1 addition & 1 deletion scripts/ohmyzsh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ do_configure() {
)
for path in "${!plugins[@]}"; do
if [[ ! -d "${ZSH_CUSTOM}/$path" ]]; then
git clone "${plugins[$path]}" "${ZSH_CUSTOM}/$path"
git clone --quiet "${plugins[$path]}" "${ZSH_CUSTOM}/$path"
fi
done

Expand Down
2 changes: 1 addition & 1 deletion scripts/rust.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ do_install() {
fi

info "[rust] Install"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
curl --silent --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
}

main() {
Expand Down
8 changes: 4 additions & 4 deletions scripts/system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ do_install() {
export DEBIAN_FRONTEND=noninteractive
sudo apt-add-repository -y ppa:git-core/ppa
sudo apt-add-repository -y ppa:neovim-ppa/stable
sudo apt-get update
sudo apt-get install -y "${packages[@]}"
sudo apt-get update -q
sudo apt-get install -q -y "${packages[@]}"
}

do_configure() {
Expand All @@ -67,11 +67,11 @@ do_configure() {
info "[system][configure] Install patched fonts"
local install_dir="/tmp/nerd-fonts"
rm -rf "${install_dir}" && mkdir -p "${install_dir}"
git clone --filter=blob:none --sparse "https://github.com/ryanoasis/nerd-fonts.git" "${install_dir}"
git clone --quiet --filter=blob:none --sparse "https://github.com/ryanoasis/nerd-fonts.git" "${install_dir}"
cd "${install_dir}"
git sparse-checkout add patched-fonts/Meslo/L/Regular
find . -type f -name '*.ttf' ! -name '*Windows*' -exec cp "{}" "${FONTS_DIR}" \;
sudo fc-cache -f -v
sudo fc-cache -f
}

main() {
Expand Down
2 changes: 1 addition & 1 deletion scripts/tmux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ do_configure() {
info "[tmux] Configure"
info "[tmux][configure] Download tpm plugin manager"
if [[ ! -d "${HOME}/.tmux/plugins/tpm" ]]; then
git clone https://github.com/tmux-plugins/tpm "${HOME}/.tmux/plugins/tpm"
git clone --quiet https://github.com/tmux-plugins/tpm "${HOME}/.tmux/plugins/tpm"
fi

info "[tmux][configure] Create config file symlink"
Expand Down
13 changes: 6 additions & 7 deletions scripts/tree-sitter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
# shellcheck source=../scripts/util.sh
source "$(pwd)/scripts/util.sh"

TS_VERSION="${TS_VERSION:=0.20.4}"
TS_VERSION="${TS_VERSION:=0.20.6}"

do_install() {
if [[ "$(tree-sitter --version 2>/dev/null)" == *"${TS_VERSION}"* ]]; then
Expand All @@ -14,16 +14,15 @@ do_install() {
fi

info "[tree-sitter] Install"
asset=$(
curl --silent "https://api.github.com/repos/tree-sitter/tree-sitter/releases/tags/v${TS_VERSION}" | jq -r '.assets // [] | .[] | select(.name | contains("linux")) | .url'
)
asset=$(curl --silent "https://api.github.com/repos/tree-sitter/tree-sitter/releases/tags/v${TS_VERSION}" | jq -r '.assets // [] | .[] | select(.name | contains("linux")) | .url')
if [[ -z $asset ]]; then
warn "Cannot find a release. Please try again later."
exit 0
fi
mkdir -p ~/bin
curl --silent --location -H "Accept: application/octet-stream" "${asset}" | gunzip -c >~/bin/tree-sitter
chmod +x ~/bin/tree-sitter
asset="https://api.github.com/repos/tree-sitter/tree-sitter/releases/assets/58406191"
local treesitter="${HOME}/bin/tree-sitter"
download_to "" "${asset}" | gunzip -c >"${treesitter}"
chmod +x "${treesitter}"
}

main() {
Expand Down
6 changes: 5 additions & 1 deletion scripts/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@ is_installed() {
download_to() {
local path=$1
local url=$2
curl --retry-connrefused --retry 5 --create-dirs -fsLo "${path}" "${url}"
local opts=(--silent --fail --retry-connrefused --retry 5 --location -H "Accept: application/octet-stream")
if [ -n "${path}" ]; then
opts+=(--create-dirs --output "${path}")
fi
curl "${opts[@]}" "${url}"
}

0 comments on commit 540c4c5

Please sign in to comment.