Skip to content

Commit

Permalink
Move ~/.binenv to XDG directory paths
Browse files Browse the repository at this point in the history
This commit changes the installation locations for `binenv` to conform
to XDG directory specifications.

Specifically, there are now two new environment variables:
 1. `BINENV_BINDIR` (pointing to `$XDG_DATA_HOME/binenv/`) is the
    location where binenv itself and all the downloaded/installed
    binaries are stored
 2. `BINENV_BINDIR` (pointing directly to `$XDG_BIN_HOME`) is the
    location where binenv creates symlinks to its `shim`

Note that this change requires complete reinstall of `binenv`, including
all currently managed tools:
 1. Uninstall _all_ binaries managed by binenv
 2. `rm -rf ~/.binenv ~/.config/binenv ~/.cache/binenv`
 3. Reload current shell (e.g., `omz reload`)
 4. Run `make binenv` (or `make binenv-tools`)
 5. Re-install all the tools
  • Loading branch information
matyama committed Mar 12, 2024
1 parent 79dc461 commit 9872551
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .config/zsh/.zshenv
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ alias rpm="rpm --dbpath=${XDG_CACHE_HOME}/rpmdb"
export CUDA_CACHE_PATH=${XDG_CACHE_HOME}/nv

# Binenv
export BINENV_HOME=${HOME}/.binenv
export BINENV_BINDIR=${XDG_DATA_HOME}/binenv
export BINENV_LINKDIR=${XDG_BIN_HOME}

# Rust
# - See: https://doc.rust-lang.org/cargo/reference/environment-variables.html
Expand Down Expand Up @@ -268,7 +269,6 @@ path+=${GOBIN}
path+=${GEM_BIN}
path+=${KREW_BIN}
path+="/usr/local/bin"
path+=${BINENV_HOME}
path+="${CABAL_DIR}/bin"
path+="${COURSIER_BIN_DIR}"
path+="${XDG_DATA_HOME}/npm/bin"
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ ZDOTDIR ?= $(XDG_CONFIG_HOME)/zsh
ZSH ?= $(XDG_DATA_HOME)/oh-my-zsh
ZSH_CUSTOM ?= $(ZSH)/custom

BINENV_BINDIR ?= $(XDG_DATA_HOME)/binenv
BINENV_LINKDIR ?= $(XDG_BIN_HOME)

FZF_BASE ?= $(XDG_DATA_HOME)/fzf

BASE16_FZF_HOME ?= $(XDG_CONFIG_HOME)/base16-fzf
Expand Down Expand Up @@ -534,7 +537,7 @@ binenv: BINENV_BIN := binenv_linux_$(DIST_ARCH)
binenv: DOWNLOAD_DIR := $(shell mktemp -d)
binenv: $(ZSH_COMPLETIONS) net-tools
ifneq ($(shell which binenv 2> /dev/null),)
@echo ">>> $@ already installed to '$(BINENV_HOME)'"
@echo ">>> $@ already installed to '$(BINENV_BINDIR)'"
else
@echo ">>> Downloading $@"
$(WGET) -q -P $(DOWNLOAD_DIR) \
Expand All @@ -545,9 +548,10 @@ else
sha256sum -c --strict --status --ignore-missing checksums.txt) || \
(echo ">>> Failed to verify checksum" && rm -rf $(DOWNLOAD_DIR) && exit 1)
@echo ">>> Installing $@"
@chmod +x "$(DOWNLOAD_DIR)/$(BINENV_BIN)"
"$(DOWNLOAD_DIR)/$(BINENV_BIN)" update
"$(DOWNLOAD_DIR)/$(BINENV_BIN)" install $@
@mv "$(DOWNLOAD_DIR)/$(BINENV_BIN)" "$(DOWNLOAD_DIR)/$@"
@chmod +x "$(DOWNLOAD_DIR)/$@"
"$(DOWNLOAD_DIR)/$@" update
"$(DOWNLOAD_DIR)/$@" install $@
@echo ">>> Generating zsh completions for $@"
$@ completion zsh > $</_$@
@echo ">>> Finish $@ completion setup by reloading zsh with 'omz reload'"
Expand Down

0 comments on commit 9872551

Please sign in to comment.