diff --git a/.gitattributes b/.gitattributes index 2e8be48f..5729e7a2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -22,6 +22,7 @@ *.sh text *.bash text *.fish text +*.elv text #### asdf/bin/* explicitly define as text *asdf text *asdf-exec text diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 87da6afc..3ec4a5eb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,15 +28,22 @@ jobs: - name: Install test dependencies if: runner.os == 'macos' - run: brew install coreutils fish + run: brew install coreutils fish elvish - name: Install test dependencies if: runner.os == 'linux' run: | - PPA="ppa:fish-shell/nightly-master" - sudo add-apt-repository -y "$PPA" + sudo add-apt-repository -y ppa:fish-shell/nightly-master sudo apt-get update - sudo apt-get -y install fish + sudo apt-get -y install fish curl + + # Download elvish binary and add to path + curl https://dl.elv.sh/linux-amd64/elvish-v0.16.3.tar.gz -o elvish-v0.16.3.tar.gz + tar xzf elvish-v0.16.3.tar.gz + rm elvish-v0.16.3.tar.gz + mkdir -p "$HOME/bin" + mv elvish-v0.16.3 "$HOME/bin/elvish" + echo "$HOME/bin" >>"$GITHUB_PATH" - name: Install bats run: | diff --git a/.gitignore b/.gitignore index fcf49ff2..69ca2959 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ -installs +/installs +/downloads /plugins -shims +/shims repository .vagrant keyrings diff --git a/README.md b/README.md index 6c0d21b8..f9f4120e 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ asdf is a CLI tool that can manage multiple language runtime versions on a per-p - support for existing config files `.node-version`, `.nvmrc`, `.ruby-version` for easy migration - automatically switches runtime versions as you traverse your directories - simple plugin system to add support for your language of choice -- shell completion available for common shells (Bash, Zsh, Fish) +- shell completion available for common shells (Bash, Zsh, Fish, Elvish) ## Documentation diff --git a/asdf.elv b/asdf.elv new file mode 100644 index 00000000..3abb2035 --- /dev/null +++ b/asdf.elv @@ -0,0 +1,244 @@ + +use re +use str +use path + +var asdf_dir = $E:HOME'/.asdf' +if (and (has-env ASDF_DIR) (!=s $E:ASDF_DIR '')) { + asdf_dir = $E:ASDF_DIR +} else { + set-env ASDF_DIR $asdf_dir +} + +var asdf_data_dir = $asdf_dir +if (and (has-env ASDF_DATA_DIR) (!=s $E:ASDF_DATA_DIR '')) { + asdf_data_dir = $E:ASDF_DATA_DIR +} + +# Add function wrapper so we can export variables +fn asdf [command @args]{ + if (==s $command 'shell') { + # set environment variables + parts = [($asdf_dir'/bin/asdf' export-shell-version elvish $@args)] + if (==s $parts[0] 'set-env') { + set-env $parts[1] $parts[2] + } elif (==s $parts[0] 'unset-env') { + unset-env $parts[1] + } + } else { + # forward other commands to asdf script + $asdf_dir'/bin/asdf' $command $@args + } +} + +fn match [argz @pats]{ + var matched = $true; + if (!= (count $argz) (count $pats)) { + matched = $false + } else { + for i [(range (count $pats))] { + pat = '^'$pats[$i]'$' + arg = $argz[$i] + if (not (re:match $pat $arg)) { + matched = $false + break + } + } + } + put $matched +} + +fn ls-shims []{ + ls $asdf_data_dir'/shims' +} + +fn ls-executables []{ + # Print all executable files and links in path + try { + find $@paths '(' -type f -o -type l ')' -print 2>/dev/null | each [p]{ + try { + if (test -x $p) { + path:base $p + } + } except { + # don't fail if permission denied + } + } + } except { + # silence default non-zero exit status + } +} + +fn ls-installed-versions [plugin_name]{ + asdf list $plugin_name | each [version]{ + put (re:replace '\s*(.*)\s*' '${1}' $version) + } +} + +fn ls-all-versions [plugin_name]{ + asdf list-all $plugin_name | each [version]{ + put (re:replace '\s*(.*)\s*' '${1}' $version) + } +} + +# Append ~/.asdf/bin and ~/.asdf/shims to PATH +for path [ + $asdf_dir'/bin' + $asdf_data_dir'/shims' +] { + if (not (has-value $paths $path)) { + paths = [ + $@paths + $path + ] + } +} + +# Setup argument completions +fn arg-completer [@argz]{ + argz = $argz[1:-1] # strip 'asdf' and trailing empty string + var num = (count $argz) + if (== $num 0) { + # list all subcommands + find $asdf_dir'/lib/commands' -name 'command-*' | each [cmd]{ + put (re:replace '.*/command-(.*)\.bash' '${1}' $cmd) + } + put 'plugin' + } else { + if (match $argz 'current') { + # asdf current + asdf plugin-list + } elif (match $argz 'env') { + # asdf env + ls-shims + } elif (match $argz 'env' '.*') { + # asdf env [util] + ls-executables + } elif (match $argz 'exec') { + # asdf exec + ls-shims + } elif (match $argz 'global') { + # asdf global + asdf plugin-list + } elif (match $argz 'global' '.*') { + # asdf global + ls-installed-versions $argz[-1] + } elif (match $argz 'install') { + # asdf install + asdf plugin-list + } elif (match $argz 'install' '.*') { + # asdf install + ls-all-versions $argz[-1] + } elif (match $argz 'install' '.*' '.*') { + # asdf install [--keep-download] + put '--keep-download' + } elif (match $argz 'latest') { + # asdf latest + asdf plugin-list + } elif (match $argz 'latest' '.*') { + # asdf latest [] + ls-all-versions $argz[-1] + } elif (match $argz 'list-all') { + # asdf list all + asdf plugin-list + } elif (match $argz 'list-all' '.*') { + # asdf list all [] + ls-all-versions $argz[-1] + } elif (match $argz 'list') { + # asdf list + asdf plugin-list + } elif (match $argz 'list' '.*') { + # asdf list [] + ls-installed-versions $argz[-1] + } elif (match $argz 'local') { + # asdf local [-p|--parent] + asdf plugin-list + put '-p' + put '--parent' + } elif (match $argz 'local' '(-p|(--parent))') { + # asdf local [-p|--parent] + asdf plugin-list + } elif (match $argz 'local' '.*') { + # asdf local [-p|--parent] + # asdf local + ls-installed-versions $argz[-1] + put '-p' + put '--parent' + } elif (match $argz 'local' '(-p|(--parent))' '.*') { + # asdf local [-p|--parent] + ls-installed-versions $argz[-1] + } elif (match $argz 'local' '.*' '(-p|(--parent))') { + # asdf local [-p|--parent] + ls-installed-versions $argz[-2] + } elif (match $argz 'local' '.*' '.*') { + # asdf local [-p|--parent] + put '-p' + put '--parent' + } elif (or (match $argz 'plugin-add') (match $argz 'plugin' 'add')) { + # asdf plugin add + asdf plugin-list-all | each [line]{ + put (re:replace '([^\s]+)\s+.*' '${1}' $line) + } + } elif (or (match $argz 'plugin-list') (match $argz 'plugin' 'list')) { + # asdf plugin list + put '--urls' + put '--refs' + put 'all' + } elif (or (match $argz 'plugin-push') (match $argz 'plugin' 'push')) { + # asdf plugin push + asdf plugin-list + } elif (or (match $argz 'plugin-remove') (match $argz 'plugin' 'remove')) { + # asdf plugin remove + asdf plugin-list + } elif (and (>= (count $argz) 3) (match $argz[:3] 'plugin-test' '.*' '.*')) { + # asdf plugin-test [--asdf-tool-version ] [--asdf-plugin-gitref ] [test-command*] + put '--asdf-plugin-gitref' + put '--asdf-tool-version' + ls-executables + ls-shims + } elif (and (>= (count $argz) 4) (match $argz[:4] 'plugin' 'test' '.*' '.*')) { + # asdf plugin test [--asdf-tool-version ] [--asdf-plugin-gitref ] [test-command*] + put '--asdf-plugin-gitref' + put '--asdf-tool-version' + ls-executables + ls-shims + } elif (or (match $argz 'plugin-update') (match $argz 'plugin' 'update')) { + # asdf plugin update + asdf plugin-list + put '--all' + } elif (match $argz 'plugin') { + # list plugin-* subcommands + find $asdf_dir'/lib/commands' -name 'command-plugin-*' | each [cmd]{ + put (re:replace '.*/command-plugin-(.*)\.bash' '${1}' $cmd) + } + } elif (match $argz 'reshim') { + # asdf reshim + asdf plugin-list + } elif (match $argz 'reshim' '.*') { + # asdf reshim + ls-installed-versions $argz[-1] + } elif (match $argz 'shim-versions') { + # asdf shim-versions + ls-shims + } elif (match $argz 'uninstall') { + # asdf uninstall + asdf plugin-list + } elif (match $argz 'uninstall' '.*') { + # asdf uninstall + ls-installed-versions $argz[-1] + } elif (match $argz 'update') { + if (== $num 1) { + # asdf update + put '--head' + } + } elif (match $argz 'where') { + # asdf where + asdf plugin-list + } elif (match $argz 'where' '.*') { + # asdf where [] + ls-installed-versions $argz[-1] + } elif (match $argz 'which') { + ls-shims + } + } +} diff --git a/asdf.fish b/asdf.fish index 15736301..854bcf11 100644 --- a/asdf.fish +++ b/asdf.fish @@ -2,9 +2,9 @@ set -x ASDF_DIR (dirname (status -f)) set -l asdf_user_shims ( if test -n "$ASDF_DATA_DIR" - echo $ASDF_DATA_DIR/shims + printf "%s\n" "$ASDF_DATA_DIR/shims" else - echo $HOME/.asdf/shims + printf "%s\n" "$HOME/.asdf/shims" end ) diff --git a/asdf.sh b/asdf.sh index ff6ecfd9..7224f9be 100644 --- a/asdf.sh +++ b/asdf.sh @@ -16,7 +16,7 @@ if [ -z "$ASDF_DIR" ]; then fi export ASDF_DIR # shellcheck disable=SC2016 -[ -d "$ASDF_DIR" ] || echo '$ASDF_DIR is not a directory' +[ -d "$ASDF_DIR" ] || printf '$ASDF_DIR is not a directory' # Add asdf to PATH # diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.md index 32a53f1d..19c97406 100644 --- a/docs/guide/getting-started.md +++ b/docs/guide/getting-started.md @@ -142,6 +142,46 @@ source /opt/asdf-vm/asdf.fish Completions are automatically configured on installation by the AUR package. ::: +::: details Elvish & Git + +Add `asdf.elv` to your `~/.elvish/rc.elv` with: + +```shell:no-line-numbers +mkdir -p ~/.elvish/lib; ln -s ~/.asdf/asdf.elv ~/.elvish/lib/asdf.elv +echo "\n"'use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv +echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv +``` + +Completions are automatically configured. + +::: + +::: details Elvish & Homebrew + +Add `asdf.elv` to your `~/.elvish/rc.elv` with: + +```shell:no-line-numbers +mkdir -p ~/.elvish/lib; ln -s (brew --prefix asdf)/libexec/asdf.elv ~/.elvish/lib/asdf.elv +echo "\n"'use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv +echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv +``` + +Completions are automatically configured. +::: + +::: details Elvish & Pacman + +Add `asdf.elv` to your `~/.elvish/rc.elv` with: + +```shell:no-line-numbers +mkdir -p ~/.elvish/lib; ln -s /opt/asdf-vm/asdf.elv ~/.elvish/lib/asdf.elv +echo "\n"'use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv +echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv +``` + +Completions are automatically configured. +::: + ::: details ZSH & Git Add the following to `~/.zshrc`: diff --git a/docs/index.md b/docs/index.md index 46e8a8a1..1ef60a1b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -19,7 +19,7 @@ features: - title: "One Config File" details: ".tool-versions to manage all your tools, runtimes and their versions in a single, sharable place." - title: "Shells" - details: "Supports Bash, ZSH & Fish with completions available." + details: "Supports Bash, ZSH, Fish & Elvish with completions available." - title: "GitHub Actions" details: "Provides a GitHub Action to install and utilize your .tool-versions in your CI/CD workflows." # footer: MIT Licensed diff --git a/docs/manage/configuration.md b/docs/manage/configuration.md index 89a95eb8..45b542e6 100644 --- a/docs/manage/configuration.md +++ b/docs/manage/configuration.md @@ -101,7 +101,7 @@ Configure the duration since the last asdf plugin repository sync to the next. C - `ASDF_CONFIG_FILE` - Defaults to `~/.asdfrc` as described above. Can be set to any location. - `ASDF_DEFAULT_TOOL_VERSIONS_FILENAME` - The filename of the file storing the tool names and versions. Defaults to `.tool-versions`. Can be any valid filename. Typically you should not override the default value unless you know you want asdf to ignore `.tool-versions` files. - `ASDF_DIR` - Defaults to `~/.asdf` - Location of the `asdf` scripts. If you install `asdf` to some other directory, set this to that directory. For example, if you are installing via the AUR, you should set this to `/opt/asdf-vm`. -- `ASDF_DATA_DIR` - Defaults to `~/.asdf` - Location where `asdf` install plugins, shims and installs. Can be set to any location before sourcing `asdf.sh` or `asdf.fish` mentioned in the section above. +- `ASDF_DATA_DIR` - Defaults to `~/.asdf` - Location where `asdf` install plugins, shims and installs. Can be set to any location before sourcing `asdf.sh` or `asdf.fish` mentioned in the section above. For Elvish, this can be set above `use asdf`. ## Internal Configuration diff --git a/docs/manage/core.md b/docs/manage/core.md index 37460875..cd005985 100644 --- a/docs/manage/core.md +++ b/docs/manage/core.md @@ -257,6 +257,99 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc ::: +::: details Elvish & Git + +1. In your `~/.elvish/rc.elv` remove the lines that use the `asdf` module: + +```shell +use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} +edit:completion:arg-completer[asdf] = $_asdf:arg-completer~ +``` + +and uninstall the `asdf` module with this command: + +```shell:no-line-numbers +rm -f ~/.elvish/lib/asdf.elv +``` + +2. Remove the `$HOME/.asdf` dir: + +```shell:no-line-numbers +if (!=s $E:ASDF_DATA_DIR "") { rm -rf $E:ASDF_DATA_DIR } else { rm -rf ~/.asdf } +``` + +3. Run this command to remove all `asdf` config files: + +```shell:no-line-numbers +rm -rf $HOME/.tool-versions $HOME/.asdfrc +``` + +::: + +::: details Elvish & Homebrew + +1. In your `~/.elvish/rc.elv` remove the lines that use the `asdf` module: + +```shell +use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} +edit:completion:arg-completer[asdf] = $_asdf:arg-completer~ +``` + +and uninstall the `asdf` module with this command: + +```shell:no-line-numbers +rm -f ~/.elvish/lib/asdf.elv +``` + +2. Uninstall with your package manager: + +```shell:no-line-numbers +brew uninstall asdf --force +``` + +3. Run this command to remove all `asdf` config files: + +```shell:no-line-numbers +rm -rf $HOME/.tool-versions $HOME/.asdfrc +``` + +::: + +::: details Elvish & Pacman + +1. In your `~/.elvish/rc.elv` remove the lines that use the `asdf` module: + +```shell +use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} +edit:completion:arg-completer[asdf] = $_asdf:arg-completer~ +``` + +and uninstall the `asdf` module with this command: + +```shell:no-line-numbers +rm -f ~/.elvish/lib/asdf.elv +``` + +2. Uninstall with your package manager: + +```shell:no-line-numbers +pacman -Rs asdf-vm +``` + +3. Remove the `$HOME/.asdf` dir: + +```shell:no-line-numbers +if (!=s $E:ASDF_DATA_DIR "") { rm -rf $E:ASDF_DATA_DIR } else { rm -rf ~/.asdf } +``` + +4. Run this command to remove all `asdf` config files: + +```shell:no-line-numbers +rm -rf $HOME/.tool-versions $HOME/.asdfrc +``` + +::: + ::: details ZSH & Git 1. In your `~/.zshrc` remove the lines that source `asdf.sh` and completions: diff --git a/docs/manage/versions.md b/docs/manage/versions.md index 0f008f54..55690de6 100644 --- a/docs/manage/versions.md +++ b/docs/manage/versions.md @@ -132,7 +132,7 @@ asdf uninstall ## Shims -When asdf installs a package it creates shims for every executable program in that package in a `$ASDF_DATA_DIR/shims` directory (default `~/.asdf/shims`). This directory being on the `$PATH` (by means of `asdf.sh` or `asdf.fish`) is how the installed programs are made available in the environment. +When asdf installs a package it creates shims for every executable program in that package in a `$ASDF_DATA_DIR/shims` directory (default `~/.asdf/shims`). This directory being on the `$PATH` (by means of `asdf.sh`, `asdf.fish`, etc) is how the installed programs are made available in the environment. The shims themselves are really simple wrappers that `exec` a helper program `asdf exec` passing it the name of the plugin and path to the executable in the installed package that the shim is wrapping. diff --git a/docs/pt-br/guide/getting-started.md b/docs/pt-br/guide/getting-started.md index b132fbc8..ee2da0d9 100644 --- a/docs/pt-br/guide/getting-started.md +++ b/docs/pt-br/guide/getting-started.md @@ -146,6 +146,46 @@ source /opt/asdf-vm/asdf.fish O auto completar é configurado automaticamente durante a instalação do pacote AUR. ::: +::: details Elvish & Git + +Add `asdf.elv` to your `~/.elvish/rc.elv` with: + +```shell:no-line-numbers +mkdir -p ~/.elvish/lib; ln -s ~/.asdf/asdf.elv ~/.elvish/lib/asdf.elv +echo "\n"'use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv +echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv +``` + +Completions are automatically configured. + +::: + +::: details Elvish & Homebrew + +Add `asdf.elv` to your `~/.elvish/rc.elv` with: + +```shell:no-line-numbers +mkdir -p ~/.elvish/lib; ln -s (brew --prefix asdf)/libexec/asdf.elv ~/.elvish/lib/asdf.elv +echo "\n"'use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv +echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv +``` + +Completions are automatically configured. +::: + +::: details Elvish & Pacman + +Add `asdf.elv` to your `~/.elvish/rc.elv` with: + +```shell:no-line-numbers +mkdir -p ~/.elvish/lib; ln -s /opt/asdf-vm/asdf.elv ~/.elvish/lib/asdf.elv +echo "\n"'use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv +echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv +``` + +Completions are automatically configured. +::: + ::: details ZSH & Git Adicione a seguinte linha ao seu `~/.zshrc`: diff --git a/docs/pt-br/index.md b/docs/pt-br/index.md index 66726990..17436268 100644 --- a/docs/pt-br/index.md +++ b/docs/pt-br/index.md @@ -19,7 +19,7 @@ features: - title: "Só um arquivo de configuração" details: ".tool-versions para gerenciar todas as suas ferramentas, runtimes e suas versões em um único arquivo" - title: "Shells" - details: "Suporta Bash, ZSH & Fish com autocomplete." + details: "Suporta Bash, ZSH, Fish & Elvish com autocomplete." - title: "GitHub Actions" details: "Fornece um GitHub Action para instalar e utilizar seu .tool-verions em seu fluxo de trabalho CICD." # footer: MIT Licensed diff --git a/docs/pt-br/learn-more/faq.md b/docs/pt-br/learn-more/faq.md index 35cd7cca..df4d0e4d 100644 --- a/docs/pt-br/learn-more/faq.md +++ b/docs/pt-br/learn-more/faq.md @@ -1,27 +1,25 @@ # Perguntas frequentes -> Hi, we've recently migrated our docs and added some new pages. If you would like to help translate this page, see the "Edit this page" link at the bottom of the page. +Aqui estão algumas perguntas comuns sobre `asdf`. -Here are some common questions regarding `asdf`. +## Suporte WSL1? -## WSL1 support? +WSL1 ([Windows Subsystem for Linux](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux) 1) não é oficialmente suportado. Alguns aspectos do `asdf` podem não funcionar corretamente. Não temos a intenção de adicionar suporte oficial para WSL1. -WSL1 ([Windows Subsystem for Linux](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux) 1) is not officially supported. Some aspects of `asdf` may not work properly. We do not intend to add official support for WSL1. +## Suporte WSL2? -## WSL2 support? +WSL2 ([Subsistema Windows para Linux](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux#WSL_2) 2) deve funcionar usando as instruções de configuração e dependência para a distribuição WSL escolhida. -WSL2 ([Windows Subsystem for Linux](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux#WSL_2) 2) should work using the setup & dependency instructions for you chosen WSL distro. +É importante ressaltar que o WSL2 _apenas_ deve funcionar corretamente quando o diretório de trabalho atual é uma unidade Unix e não uma unidade Windows vinculada. -Importantly, WSL2 is _only_ expected to work properly when the current working directory is a Unix drive and not a bound Windows drive. +Pretendemos executar o conjunto de testes no WSL2 quando o suporte ao host runner estiver disponível nas Ações do GitHub; atualmente, esse não parece ser o caso. -We intend to run out test suite on WSL2 when host runner support is available on GitHub Actions, currently this does not appear to be the case. +## Exectable recém-instalado não está funcionando? -## Newly installed exectable not running? +> Acabei de instalar o `npm -g yarn`, mas não consigo executar o `yarn`. O que da? -> I just `npm install -g yarn`, but cannot execute `yarn`. What gives? +`asdf` usa [shims]() para gerenciar executáveis. Aqueles instalados por plug-ins têm shims criados automaticamente, enquanto a instalação de executáveis ​​por meio de uma ferramenta gerenciada `asdf` exigirá que você notifique o` asdf` sobre a necessidade de criar shims. Neste caso, para criar um shim para [Yarn](https://yarnpkg.com/). Veja a documentação do comando [`asdf reshim`](/ manage / core.md # reshim). -`asdf` uses [shims]() to manage executables. Those installed by plugins have shims automatically created, whereas installing executables via an `asdf` managed tool will require you to notify `asdf` of the need to create shims. In this instance, to create a shim for [Yarn](https://yarnpkg.com/). See the [`asdf reshim` command docs](/manage/core.md#reshim). +## Shell não detecta shims recém-instalados? -## Shell not detecting newly installed shims? - -If `asdf reshim` is not resolving your issue, then it is most-likely due to the sourcing of `asdf.sh` or `asdf.fish` _not_ being at the **BOTTOM** of your Shell config file (`.bash_profile`, `.zshrc`, `config.fish` etc). It needs to be sourced **AFTER** you have set your `$PATH` and **AFTER** you have sourced your framework (oh-my-zsh etc) if any. +Se `asdf reshim` não está resolvendo seu problema, então é mais provável devido ao sourcing de` asdf.sh` ou `asdf.fish` _não_ estar no ** BOTTOM ** de seu arquivo de configuração Shell (`.bash_profile`, `.zshrc`, ` config.fish`, etc). Ele precisa ser fornecido **DEPOIS** de você definir seu `$PATH` e **DEPOIS** de ter fornecido seu framework (oh-meu-zsh etc), se houver. diff --git a/docs/pt-br/manage/configuration.md b/docs/pt-br/manage/configuration.md index 49c29784..3f0c4cb0 100644 --- a/docs/pt-br/manage/configuration.md +++ b/docs/pt-br/manage/configuration.md @@ -59,4 +59,4 @@ legacy_version_file = yes - `ASDF_CONFIG_FILE` - O padrão é `~ / .asdfrc` conforme descrito acima. Pode ser definido para qualquer local. - `ASDF_DEFAULT_TOOL_VERSIONS_FILENAME` - O nome do arquivo que armazena os nomes e versões das ferramentas. O padrão é `.tool-versions`. Pode ser qualquer nome de arquivo válido. Normalmente você não deve substituir o valor padrão, a menos que deseja que o asdf ignore os arquivos `.tool-versions`. - `ASDF_DIR` - O padrão é `~/.asdf` - Localização dos arquivos `asdf`. Se você instalar `asdf` em algum outro diretório, defina-o para esse diretório. Por exemplo, se você estiver instalando através do AUR, você deve definir isso para `/ opt / asdf-vm`. -- `ASDF_DATA_DIR` - O padrão é `~/.asdf` - Local onde `asdf` instala plugins, correções e instalações. Pode ser definido para qualquer local antes de fornecer `asdf.sh` ou`asdf.fish` mencionado na seção acima. +- `ASDF_DATA_DIR` - O padrão é `~/.asdf` - Local onde `asdf` instala plugins, correções e instalações. Pode ser definido para qualquer local antes de fornecer `asdf.sh` ou `asdf.fish` mencionado na seção acima. Para Elvish, isso pode ser definido acima de `use asdf`. diff --git a/docs/pt-br/manage/core.md b/docs/pt-br/manage/core.md index 7fd9839f..39d444bd 100644 --- a/docs/pt-br/manage/core.md +++ b/docs/pt-br/manage/core.md @@ -259,6 +259,99 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc ::: +::: details Elvish & Git + +1. Em seu `~/.elvish/rc.elv` remova as linhas que importa o módulo `asdf`: + +```shell +use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} +edit:completion:arg-completer[asdf] = $_asdf:arg-completer~ +``` + +e desinstale o módulo `asdf` com este comando: + +```shell:no-line-numbers +rm -f ~/.elvish/lib/asdf.elv +``` + +2. Remova o diretório `$HOME/.asdf`: + +```shell:no-line-numbers +if (!=s $E:ASDF_DATA_DIR "") { rm -rf $E:ASDF_DATA_DIR } else { rm -rf ~/.asdf } +``` + +3. Execute este comando para remover todos os arquivos de configuração `asdf`: + +```shell:no-line-numbers +rm -rf $HOME/.tool-versions $HOME/.asdfrc +``` + +::: + +::: details Elvish & Homebrew + +1. Em seu `~/.elvish/rc.elv` remova as linhas que importa o módulo `asdf`: + +```shell +use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} +edit:completion:arg-completer[asdf] = $_asdf:arg-completer~ +``` + +e desinstale o módulo `asdf` com este comando: + +```shell:no-line-numbers +rm -f ~/.elvish/lib/asdf.elv +``` + +2. Desinstale com seu gerenciador de pacotes: + +```shell:no-line-numbers +brew uninstall asdf --force +``` + +3. Execute este comando para remover todos os arquivos de configuração `asdf`: + +```shell:no-line-numbers +rm -rf $HOME/.tool-versions $HOME/.asdfrc +``` + +::: + +::: details Elvish & Pacman + +1. Em seu `~/.elvish/rc.elv` remova as linhas que importa o módulo `asdf`: + +```shell +use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} +edit:completion:arg-completer[asdf] = $_asdf:arg-completer~ +``` + +e desinstale o módulo `asdf` com este comando: + +```shell:no-line-numbers +rm -f ~/.elvish/lib/asdf.elv +``` + +2. Desinstale com seu gerenciador de pacotes: + +```shell:no-line-numbers +pacman -Rs asdf-vm +``` + +3. Remova o diretório `$ HOME/.asdf`: + +```shell:no-line-numbers +if (!=s $E:ASDF_DATA_DIR "") { rm -rf $E:ASDF_DATA_DIR } else { rm -rf ~/.asdf } +``` + +4. Execute este comando para remover todos os arquivos de configuração `asdf`: + +```shell:no-line-numbers +rm -rf $HOME/.tool-versions $HOME/.asdfrc +``` + +::: + ::: details ZSH & Git 1. Em seu `~/.zshrc` remova as linhas do `asdf.sh` e seus complementos: diff --git a/docs/pt-br/manage/versions.md b/docs/pt-br/manage/versions.md index aae9386e..89a00dc2 100644 --- a/docs/pt-br/manage/versions.md +++ b/docs/pt-br/manage/versions.md @@ -133,7 +133,7 @@ asdf uninstall ## Shims -Quando asdf instala um pacote é criado _shims_ para cada programa executado no pacote do diretório `$ASDF_DATA_DIR/shims` (padrão `~/.asdf/shims`). Esse diretório começa no `$PATH` (pelos `asdf.sh` ou `asdf.fish`) é como o programa instalado é disponibilizado no ambiente do sistema. +Quando asdf instala um pacote é criado _shims_ para cada programa executado no pacote do diretório `$ASDF_DATA_DIR/shims` (padrão `~/.asdf/shims`). Esse diretório começa no `$PATH` (pelos `asdf.sh`, `asdf.fish`, etc) é como o programa instalado é disponibilizado no ambiente do sistema. Os _shims_ em si são atalhos simples que executam um programa auxiliar `asdf exec` passando o nome do plugin e o caminho para o executável no pacote instalado que o _shim_ está contido. diff --git a/lib/commands/command-export-shell-version.bash b/lib/commands/command-export-shell-version.bash index 6e3fa371..3403176b 100644 --- a/lib/commands/command-export-shell-version.bash +++ b/lib/commands/command-export-shell-version.bash @@ -23,6 +23,12 @@ shell_command() { fish) printf "set -e %s\\n" "$version_env_var" ;; + elvish) + # Elvish doesn't have a `source` command, and eval is banned, so the + # var name and value are printed on separate lines for asdf.elv to parse + # and pass to unset-env. + printf "unset-env\n%s" "$version_env_var" + ;; *) printf "unset %s\\n" "$version_env_var" ;; @@ -42,6 +48,12 @@ shell_command() { fish) printf "set -gx %s \"%s\"\\n" "$version_env_var" "$version" ;; + elvish) + # Elvish doesn't have a `source` command, and eval is banned, so the + # var name and value are printed on separate lines for asdf.elv to parse + # and pass to set-env. + printf "set-env\n%s\n%s" "$version_env_var" "$version" + ;; *) printf "export %s=\"%s\"\\n" "$version_env_var" "$version" ;; diff --git a/test/asdf_elvish.bats b/test/asdf_elvish.bats new file mode 100644 index 00000000..b585ef3c --- /dev/null +++ b/test/asdf_elvish.bats @@ -0,0 +1,98 @@ +#!/usr/bin/env bats + +load test_helpers + +setup() { + cd $(dirname "$BATS_TEST_DIRNAME") + mkdir -p $HOME/.elvish/lib + cp ./asdf.elv $HOME/.elvish/lib/asdftest.elv +} + +teardown() { + rm $HOME/.elvish/lib/asdftest.elv +} + +cleaned_path() { + echo $PATH | tr ':' '\n' | grep -v "asdf" | tr '\n' ' ' +} + +@test "exports ASDF_DIR" { + output=$(elvish -norc -c " + unset-env ASDF_DIR + paths = [$(cleaned_path)] + use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} + echo \$E:ASDF_DIR + ") + [ "$?" -eq 0 ] + [ "$output" = "$HOME/.asdf" ] +} + +@test "retains ASDF_DIR" { + output=$(elvish -norc -c " + set-env ASDF_DIR "/path/to/asdf" + paths = [$(cleaned_path)] + use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} + echo \$E:ASDF_DIR + ") + [ "$?" -eq 0 ] + [ "$output" = "/path/to/asdf" ] +} + +@test "retains ASDF_DATA_DIR" { + output=$(elvish -norc -c " + set-env ASDF_DATA_DIR "/path/to/asdf-data" + paths = [$(cleaned_path)] + use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} + echo \$E:ASDF_DATA_DIR + ") + [ "$?" -eq 0 ] + [ "$output" = "/path/to/asdf-data" ] +} + +@test "adds asdf dirs to PATH" { + result=$(elvish -norc -c " + unset-env ASDF_DIR + paths = [$(cleaned_path)] + use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} + echo \$E:PATH + ") + [ "$?" -eq 0 ] + echo "$result" + output=$(echo "$result" | grep "asdf") + [ "$output" != "" ] +} + +@test "defines the _asdf namespace" { + output=$(elvish -norc -c " + unset-env ASDF_DIR + paths = [$(cleaned_path)] + use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} + pprint \$_asdf: + ") + [ "$?" -eq 0 ] + [[ "$output" =~ "