Getting Started
Installation
Arch Linux
git clone https://github.com/deorbil-aur/zd-git.git
cd zd-git
makepkg -si
Building from Source
Install the following tools:
Install the following dependencies:
This will clone the repository, build the project, and create an executable in the target/release
directory.
git clone https://github.com/deorbil/zd.git
cd zd
cargo build --release --locked
TIP
Move the executable to a directory in your PATH
(such as /usr/local/bin
or ~/.local/bin
):
sudo cp target/release/zd /usr/local/bin/
cp target/release/zd ~/.local/bin/
Setup
Bash
Add the following to your ~/.bashrc
:
eval "$(zd init bash)"
Zsh
Add the following to your ~/.zshrc
:
eval "$(zd init zsh)"
Adding Directories
By default, zd will use your default shell as the script interpreter.
Bash
Create a new file ~/.zdrc
with the following content to add your first directory:
#!/usr/bin/env bash
echo "$HOME"
TIP
You can add more directories using echo
or any other command that outputs directory paths. For example, use find
to add multiple directories:
#!/usr/bin/env bash
echo "$HOME"
find "$HOME/source" -maxdepth 1 -type d
Zsh
Create a new file ~/.zdrc
with the following content to add your first directory:
#!/usr/bin/env zsh
echo "$HOME"
TIP
You can add more directories using echo
or any other command that outputs directory paths. For example, use find
to add multiple directories:
#!/usr/bin/env zsh
echo "$HOME"
find "$HOME/source" -maxdepth 1 -type d
Alternatively, replace ~/.zdrc
with an executable. This can be either a binary or a shebang script.
Binary
Move the binary to ~/.zdrc
, then make it executable:
chmod +x ~/.zdrc
Lua
Add the following to your ~/.zdrc
:
#!/usr/bin/env lua
print(os.getenv("HOME"))
Make ~/.zdrc
executable:
chmod +x ~/.zdrc
Node.js
Add the following to your ~/.zdrc
:
#!/usr/bin/env node
const os = require("os");
console.log(os.homedir());
Make ~/.zdrc
executable:
chmod +x ~/.zdrc
Python
Add the following to your ~/.zdrc
:
#!/usr/bin/env python3
import os
print(os.path.expanduser("~"))
Make ~/.zdrc
executable:
chmod +x ~/.zdrc
Installing a Plugin
Install the zd-cd plugin:
zd plugin add cd https://github.com/deorbil/zd-cd.git
Then reload your shell and run the following command:
z