add: direnv config
This commit is contained in:
parent
d2cef582c7
commit
579bfd4048
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
direnv
|
||||
@ -1,11 +1,11 @@
|
||||
# user/id-mrjk
|
||||
# direnv
|
||||
Just a bunch of dotfiles.
|
||||
|
||||
## Install
|
||||
Clone and symlink or install with [ellipsis][ellipsis]:
|
||||
|
||||
```
|
||||
$ ellipsis install user/id-mrjk
|
||||
$ ellipsis install direnv
|
||||
```
|
||||
|
||||
[ellipsis]: http://ellipsis.sh
|
||||
|
||||
65
ellipsis.sh
65
ellipsis.sh
@ -1,18 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# user/id-mrjk ellipsis package
|
||||
# direnv ellipsis package
|
||||
|
||||
|
||||
ELLIPSIS_SHELL_BIN="$HOME/.local/bin"
|
||||
ELLIPSIS_SHELL_=
|
||||
ELLIPSIS_SHELL_HOME="$HOME/.local/shell"
|
||||
|
||||
detect_platform() {
|
||||
|
||||
local kernel= machine=
|
||||
|
||||
kernel=$(uname -s | tr "[:upper:]" "[:lower:]")
|
||||
case "${kernel}" in
|
||||
mingw*)
|
||||
kernel=windows
|
||||
Darwin)
|
||||
kernel=macOS
|
||||
;;
|
||||
esac
|
||||
case "$(uname -m)" in
|
||||
@ -38,42 +39,60 @@ detect_platform() {
|
||||
get_github_release () {
|
||||
local repo=$1
|
||||
local pattern=$2
|
||||
local version=${3:-latest}
|
||||
local version=${3-}
|
||||
|
||||
if [[ -n "${version:-}" ]]; then
|
||||
gh_url_suffix="tags/${version}"
|
||||
else
|
||||
gh_url_suffix="latest"
|
||||
fi
|
||||
if [[ -n "${version:-}" ]] && [[ "$version" != 'latest' ]]; then
|
||||
gh_url_suffix="tags/${version}"
|
||||
else
|
||||
gh_url_suffix="latest"
|
||||
fi
|
||||
|
||||
download_url=$(
|
||||
curl -fL "https://api.github.com/repos/direnv/direnv/releases/$gh_url_suffix" \
|
||||
curl -fL "https://api.github.com/repos/$repo/releases/$gh_url_suffix" \
|
||||
| grep browser_download_url \
|
||||
| cut -d '"' -f 4 \
|
||||
| grep "$pattern"
|
||||
)
|
||||
|
||||
if [[ "$version" == 'latest' ]]; then
|
||||
echo "$download_url" | head -n 1
|
||||
else
|
||||
echo "$download_url" | grep "$version" | head -n 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# The following hooks can be defined to customize behavior of your package:
|
||||
pkg.install() {
|
||||
fs.link_files $PKG_PATH
|
||||
set -x
|
||||
|
||||
eval "$(detect_platform)"
|
||||
download_url=$(get_github_release direnv/direnv "direnv.$kernel.$machine" latest)
|
||||
local bin=direnv
|
||||
|
||||
#download_url=$(
|
||||
# curl -fL "https://api.github.com/repos/direnv/direnv/releases/$gh_url_suffix" \
|
||||
# | grep browser_download_url \
|
||||
# | cut -d '"' -f 4 \
|
||||
# | grep "direnv.$kernel.$machine"
|
||||
#)
|
||||
# Fetch archive
|
||||
if ! fs.file_exists $PKG_PATH/$bin; then
|
||||
local download_url= kernel= machine=
|
||||
eval "$(detect_platform)"
|
||||
download_url=$(get_github_release direnv/direnv "direnv.$kernel-$machine" latest)
|
||||
curl -o "$PKG_PATH/$bin" -fL "$download_url"
|
||||
fi
|
||||
chmod +x "$bin"
|
||||
|
||||
mkdir -p "$ELLIPSIS_SHELL_BIN"
|
||||
curl -o "$ELLIPSIS_SHELL_BIN/direnv" -fL "$download_url"
|
||||
chmod a+x "$ELLIPSIS_SHELL_BIN/direnv"
|
||||
set +x
|
||||
}
|
||||
|
||||
pkg.uninstall() {
|
||||
local bin=direnv
|
||||
if fs.file_exists $PKG_PATH/$bin; then
|
||||
rm $PKG_PATH/$bin
|
||||
fi
|
||||
}
|
||||
|
||||
pkg.link() {
|
||||
local bin=direnv
|
||||
if ! fs.file_exists $PKG_PATH/$bin; then
|
||||
pkg.install
|
||||
fi
|
||||
fs.link_rfile $bin $ELLIPSIS_SHELL_BIN/$bin
|
||||
}
|
||||
|
||||
# pkg.push() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user