aliae icon indicating copy to clipboard operation
aliae copied to clipboard

feat: if improvements

Open kiliantyler opened this issue 1 year ago • 0 comments

Prerequisites

  • [x] I have read and understood the contributing guide.
  • [x] The commit message follows the conventional commits guidelines.
  • [x] Tests for the changes have been added (for bug fixes / features).
  • [x] Docs have been added/updated (for bug fixes / features).

Main new features

  • If now supports both a string and a list
  • slim-sprig added to templates
  • new runtime variables (.User, .ConfigDir, .CacheDir, .Hostname)

Ifs

This allows If to be a string as it currently is:

alias:
  - name: hello
    value: world
    if: eq .Shell "zsh"

But also allows it to be a list:

alias:
  - name: hello
    value: world
    if:
      - eq .Shell "zsh"
      - match .User "root"

slim-sprig

This incorporates slim-sprig template functions into templates. The slim version was chosen since most of the features in the full version that are missing are expensive and unneeded.

New runtime variables

  • .User -- The username of the current user
  • .Hostname -- The current machine's hostname
  • .ConfigDir -- The current user's config directory based on OS
    • Unix: $XDG_CONFIG_HOME (or $HOME/.config if empty)
    • MacOS: $HOME/Library/Application Support
    • Windows: %AppData%
  • .CacheDir -- The current user's cache directory based on OS
    • Unix: $XDG_CACHE_HOME (or $HOME/.cache if empty)
    • MacOS: $HOME/Library/Caches
    • Windows: %LocalAppData%

Additional changes

  • Refactored the various rendering switches to be in one place, allowing for new shells to be added easier. Also added interfaces for the various "types" of exports to conform to Renderer
  • Added install instructions for the zinit zsh plugin manager

kiliantyler avatar Apr 27 '24 22:04 kiliantyler