GithubHelp home page GithubHelp logo

curryeleison / zsh-asdf-prompt Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 0.0 27 KB

Prompt info for asdf users in zsh

License: Apache License 2.0

Shell 100.00%
zsh oh-my-zsh-plugin asdf-vm cli zsh-configuration

zsh-asdf-prompt's Introduction

asdf-prompt plugin for zsh/oh-my-zsh

A zsh prompt for asdf users that displays information about your current tool versions.

Examples

The plugin will by default stay quiet when asdf tool versions are at your global settings.

If you are in a folder affected by a .tool-versions file or have set a $ASDF_*_VERSION it will list the changed versions. Here, I have tweaked versions of python and nodejs:
Screenshot #1.1

You can embellish with details on versions and version resolution with the $ZSH_THEME_ASDF_PROMPT_* environment variables:
Screenshot #1.2
See section on environment variables further down to learn about the options.

Requirements

Currently only really tested with oh-my-zsh.

Install

Run

git clone https://github.com/CurryEleison/zsh-asdf-prompt.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-asdf-prompt

to install the plugin into your custom folder. Activate the plugin in ~/.zshrc:

plugins=( [plugins...] zsh-asdf-prompt)

Add the prompt info in your theme with $(asdf_prompt_info). E.g.

PROMPT='%n@%m $(asdf_prompt_info)${(s:/:)PWD/#$HOME/~}%(!.#.>) '
ZSH_THEME_ASDF_PROMPT_PREFIX="%{$fg_bold[magenta]%}{"
ZSH_THEME_ASDF_PROMPT_POSTFIX="}%{$reset_color%} "
ZSH_THEME_ASDF_PROMPT_VERSION_RESOLUTION="COMPACT"

Environment variables in use

  • ZSH_THEME_ASDF_PROMPT_PREFIX: Prompt prefix. Default to {
  • ZSH_THEME_ASDF_PROMPT_POSTFIX: Prompt postfix. Default to }
  • ZSH_THEME_ASDF_PROMPT_FILTER: Tools to show in prompt. COMPACT, USER or ALL. Default to COMPACT
    • ALL shows all asdf tools
    • USER shows all that are not using system version
    • COMPACT shows tools that are not system and not the default version for the user as defined by ~/.tool-versions
  • ZSH_THEME_ASDF_PROMPT_VERSION_DETAIL: Version detail. MINOR, MAJOR or PATCH
    • MINOR: Show major + minor version. Like "python: 3.10, nodejs: 17.4"
    • MAJOR: Show major version. Like "python: 3, nodejs: 17"
    • PATCH: Include patch version. Like "python: 3.10.1, nodejs: 17.4.0"
  • ZSH_THEME_ASDF_PROMPT_VERSION_RESOLUTION: Show how version was resolved. COMPACT or NONE. Default is NONE
    • NONE: Omit version resolution info
    • COMPACT: Show how asdfresolved versions
      • "$" is from ASDF_<TOOLNAME>_VERSION environment variables
      • "~" from .tool-versions in home dir
      • "." from .tool-versions in current dir
      • "/" from .tool-versions in other parent dir

zsh-asdf-prompt's People

Contributors

curryeleison avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

zsh-asdf-prompt's Issues

No tools are shown in the prompt if there is only one entry in the .tool-versions

Thank you for that library!

I have noticed an issue. If there is only one entry in the .tool-versions, the prompt is shown as {}. If I add a second one, the prompt lists both properly.

{} ~/quails | main
$ cat .tool-versions 
ruby 3.1.2

{} ~/quails | main
$ asdf_prompt_info
{} 

{} ~/quails | main
$ echo "elixir  1.13.4" >> .tool-versions

{elixir: 1.13.4, ruby: 3.1.2} ~/quails | main
$ asdf_prompt_info                       
{elixir: 1.13.4, ruby: 3.1.2} 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.