Crates.io | rualdi |
lib.rs | rualdi |
version | 0.2.3 |
source | src |
created_at | 2020-09-19 23:15:55.095774 |
updated_at | 2021-12-02 04:35:58.722194 |
description | Rust Aliasing Directory |
homepage | |
repository | https://github.com/Jarsop/rualdi |
max_upload_size | |
id | 290561 |
size | 171,230 |
%HASH
mapping differentlybg
, and TrueColor
supportradf
function%HASH
in radf
functionfzf
: tokio
and async
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.
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
rualdi
cargo install rualdi -f
cargo build --release
cp target/release/rualdi <path>
Where <path>
is the path where you store your binaries.
cargo install cargo-deb
cargo deb
sudo dpkg -i /target/debian/rualdi_<version>_<arch>.deb
You can download a pre-compiled .deb
package from the
releases page and add run:
sudo dpkg -i /target/debian/rualdi_<version>_<arch>.deb
Alternatively, you can also download a pre-compiled binary from the
releases page and add it to
your PATH
.
rualdi
to your shellCurrently only bash
and zsh
are supported.
bash
Add the following line to your ~/.bashrc
:
eval "$(rualdi init bash)"
zsh
Add the following line to your ~/.zshrc
:
eval "$(rualdi init zsh)"
init
flags--cmd
: change the rad
command (and corresponding aliases) to something else.$_RAD_ALIASES_DIR
: directory where rualdi
will store its aliases configuration file
(default: platform-specific; see the [dirs-next
documentation] for more information)$_RAD_NO_ECHO
: when set to 1
, rad
will not print the matched directory before navigating to it$_RAD_RESOLVE_SYMLINKS
: when set to 1
, rad
will resolve symlinks before print the matched directory.[colors]
sectionThe default colors that are used are the following, and can be found in the $_RAD_ALIASES_DIR/rualdi.toml
file.
[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]
sectionSometimes 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.
[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:
[alias_hash]
use_default = "on"
use_default = "1" # Must be a string
use_default = "yes"
fzf
integrationRequires:
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.
# A query here is optional
radf <query>
pushd
wrapper# This can be any digit
radf -3
# A query here is optional
radf -d <query>
rad
wrapper# 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 <query>
As of now, only zsh
completions are available.
This works the best with fzf-tab
, which completes your command with fzf
when using <TAB>
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.
rualdi completions shell zsh > _rualdi
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:
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