Rualdi (Rust Aliasing Directory)

crates.io Crates.io Travis (.com) GitHub Workflow Status (branch) GitHub Workflow Status GitHub Workflow Status GitHub releases Crates.io Codecov

asciicast

TODO

Table of Contents

Introduction

Rualdi allows you to create aliases for directories and provides an encapsulation of the builtin cd command for easy change of the working directory. You can also add environment variable which points on an alias. All variables sourced in your environment are prefixed by RAD_.

Inspired by zoxide code.

Examples

```sh rada workdir # Add current directory with workdir as alias rada www /var/www # Add /var/www directory with www as alias rada stuff ~/stuff # Works with home tilde alias

radax workdir # Add current directory with workdir as alias # and add environment variable named RAD_WORKDIR # in current environment and in configuration file

radax workdir . wd # Add current directory with workdir as alias # and add environment variable named RAD_WD # in current environment and to the configuration file

radx workdir wd # Add environment variable named RAD_WD which points # on alias workdir in current environment # and to the configuration file

radx workdir # Add environment variable named RAD_WORKDIR # which points on alias workdir in current environment # and to the configuration file

radxn workdir wd # Add environment variable named RAD_WD which points # on alias workdir in current environment # without adding it to the configuration file

rad www/some-site # Perform cd in /var/www/some-site rad - # Go back to previous directory by cd'ing to it rad -4 # With zsh, this acts as a pushd wrapper

radr workdir # Remove workdir alias and environment variable associated if exists radr www stuff # Works with multiple aliases at same time

radrx workdir # Remove environment variable which points on alias workdir

radl # List aliases and environment variables

radf # List directories with fzf and cd to selection # There are several more options with this function explained below ```

Getting started

Step 1: Installing rualdi

From Cargo registry

sh cargo install rualdi -f

From source

sh cargo build --release cp target/release/rualdi <path> Where <path> is the path where you store your binaries.

On Debian

From source

sh cargo install cargo-deb cargo deb sudo dpkg -i /target/debian/rualdi_<version>_<arch>.deb

From .deb pre-built released

You can download a pre-compiled .deb package from the releases page and add run:

sh sudo dpkg -i /target/debian/rualdi_<version>_<arch>.deb

Other (via pre-compiled binary) GitHub releases

Alternatively, you can also download a pre-compiled binary from the releases page and add it to your PATH.

Step 2: Adding rualdi to your shell

Currently only bash and zsh are supported.

bash

Add the following line to your ~/.bashrc:

sh eval "$(rualdi init bash)"

zsh

Add the following line to your ~/.zshrc:

sh eval "$(rualdi init zsh)"

Configuration

init flags

Environment variables

[colors] section

The default colors that are used are the following, and can be found in the $_RAD_ALIASES_DIR/rualdi.toml file. toml [colors] name = "bright yellow" separator = "bright cyan" path = "magenta" The available colors are: * red, bright red * yellow, bright yellow * green, bright green * blue, bright blue * cyan, bright cyan * magenta, bright magenta * white, bright white * black, bright black

[alias_map] section

Sometimes the paths can get fairly long, so it is possible to create a hash (really an IndexMap) that will map common paths to something like the following:

/Users/user/.config/zsh/zsh.d = %ZDOTDIR/zsh.d

It can be configured in rualdi.toml, and it is possible to use both a tilde (~) and environment variables. The left-side is what will be prefixed with a % and displayed.

NOTE: It is wise to create the hash with the most specific variables at the beginning, and the least specific variables at the end. toml [alias_hash] ZDOTDIR = "$ZDOTDIR" XDG_CONFIG_HOME = "/Users/user/.config" XDG_CACHE_HOME = "~/.cache" XDG_DATA_HOME = "${HOME}/.local/share" HOME = "$HOME"

There are already several of these mappings that are ready to be implemented and can be turn on with any of the three: toml [alias_hash] use_default = "on" use_default = "1" # Must be a string use_default = "yes"

fzf integration

Requires: * fzf

The command radf (or <your_cmd>f) provides a way to use rualdi like formarks (a zsh plugin), which allows one to display the directory aliases with fzf and then cd to the selection.

No arguments

```sh

A query here is optional

radf ```

pushd wrapper

```sh

This can be any digit

radf -3 ```

Recently visited directories

```sh

A query here is optional

radf -d ```

rad wrapper

```sh

Will also go back to most recently visited directory

radf - rad -

If query is an exact match with an alias, then it's the same behavior as rad

radf ```

Completions

As of now, only zsh completions are available. This works the best with fzf-tab, which completes your command with fzf when using <TAB>

Installation

This command prints the completions to stdout, so it can be redirected to file file and placed in your fpath. These completions only work with the actual rualdi binary, and therefore will not work with the aliases that are set because they are all individual functions.

To get completions for the aliases, move the file completions/_rualdi_funcs into your fpath as well.

sh rualdi completions shell zsh > _rualdi

Extra

Subcommand Aliases

Another way to use rualdi is to set rualdi itself to an alias, and use each subcommands' own alias.

For example, in your .zshrc or .bashrc, place alias r="rualdi". Then use the following aliases:

```sh r a # rualdi add r ax # rualdi add-env r i # rualdi init r l # rualdi list r la # rualdi list-alias r lx # rualdi list-env r r # rualdi remove r rx # rualdi remove-env r res # rualdi resolve r resx # rualdi resolve-env

r comp # rualdi completions ```

Documentation for Crates