Anchor is a CLI designed to streamline your navigation in the terminal. The main purpose of this tool is to allow you to go to your saved directory anchor automatically whenever you open your terminal. This is particularly helpful for project management, as you can easily navigate to different project directories saved as anchors.
- Automatically Navigate to Default Anchor: Open your terminal to your saved anchor automatically, every time.
- Project Management: Manage your various project directories by saving them as named anchors.
- Easy Navigation: Use simple commands to navigate between your anchors, save new ones, and more.
Below are the available commands for the Anchor CLI.
Set the current directory or a named anchor as the default directory to automatically navigate to.
anchor down [anchor_name]
Unset the current default directory.
anchor up
Save the current directory as a named anchor for easy project navigation.
anchor save [anchor_name]
Go to your saved anchor whenever you open your terminal, or manually navigate to one of your saved named anchors.
anchor go [anchor_name]
Use the -f
flag to enable fuzzy finding mode, allowing you to easily search and select an anchor from your saved anchors:
anchor go -f
Delete a saved anchor directory.
anchor remove [anchor_name]
Get the path of the current anchor.
anchor get
List the current saved project directories.
anchor list
Generate the completion script for different shell environments.
anchor completion [bash|zsh|fish|powershell]
Before proceeding with the installation, please ensure that you have the Go programming language installed on your system. Having Go properly set up is essential for compiling the anchor binary from source. If you don't have it installed, you can follow the official installation guide to set up Go in your environment.
git clone git@github.com:stephanoumenos/anchor.git
cd anchor && go build
sudo cp anchor /usr/local/bin/
Run this one-liner to integrate anchor
into your zsh shell:
echo 'anchor() {\
if [[ $$1 == "go" ]]; then\
local anchor_path="$$(command anchor go $$2 2>/dev/null)";\
if [[ -n $$anchor_path ]]; then\
cd "$$anchor_path";\
elif [[ -n $$2 ]]; then\
echo "⛵️ No saved anchor named '\''$$2'\'' found.";\
else\
echo "⛵️ No default anchor set. Use '\''anchor down'\'' to set your current directory as the default.";\
fi;\
else\
command anchor "$$@";\
fi\
}\
\
if [[ $$PWD == $$HOME ]]; then\
eval "cd $$(anchor get)";\
fi\
source <(anchor completion zsh)' >> ~/.zshrc
Run this one-liner to integrate anchor
into your bash shell:
echo 'anchor() {\
if [[ $$1 == "go" ]]; then\
local anchor_path="$$(command anchor go $$2 2>/dev/null)";\
if [[ -n $$anchor_path ]]; then\
cd "$$anchor_path";\
elif [[ -n $$2 ]]; then\
echo "⛵️ No saved anchor named '\''$$2'\'' found.";\
else\
echo "⛵️ No default anchor set. Use '\''anchor down'\'' to set your current directory as the default.";\
fi;\
else\
command anchor "$$@";\
fi\
}\
\
if [[ $$PWD == $$HOME ]]; then\
eval "cd $$(anchor get)";\
fi\
source <(anchor completion bash)' >> ~/.bashrc
Run this one-liner to integrate anchor
into your fish shell:
echo 'function anchor\
if test $$argv[1] = "go";\
set anchor_path (command anchor go $$argv[2] 2>/dev/null);\
if test -n $$anchor_path;\
cd $$anchor_path;\
else if test -n $$argv[2];\
echo "⛵️ No saved anchor named '\''$$argv[2]'\'' found.";\
else;\
echo "⛵️ No default anchor set. Use '\''anchor down'\'' to set your current directory as the default.";\
end;\
else;\
command anchor $$argv;\
end;\
end\
\
if test $$PWD = $$HOME;\
eval "cd (anchor get)";\
end\
anchor completion fish | source' >> ~/.config/fish/config.fish
Now, restart your shell or run one of the following to apply the changes:
- For zsh:
source ~/.zshrc
- For bash:
source ~/.bashrc
- For fish:
source ~/.config/fish/config.fish
Enjoy using anchor
to enhance your navigation between directories!