Skip to content

volatxs/bookmarks.nu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Bookmarks.nu

A simple Nushell script that introduces commands for bookmarking and navigating around directories with a local-first philosophy.

# Create a new bookmark named "myproj" that points to "D:/code/my_project"
bookmark create myproj D:/code/my_project

# Create another bookmark pointing to the current directory
bookmark create another

# Jump to your newly created bookmark
bookmark go myproj

# Rename your bookmark
bookmark rename myproj main_project

# Save your bookmarks to the default location
bookmark save

# Save your bookmarks to a specific file
bookmark save my_bookmarks

# Load your bookmarks from the default location
bookmark load

Setup

There are many ways to do it, but here is a very simple one.

Clone this project as a local directory named bookmark in your Nushell config directory.

cd ($nu.config-path | path dirname)
git clone https://github.com/volatxs/bookmarks.nu.git bookmark

Add these two lines to your config.nu.

use bookmark  # Import the bookmarks module
bookmark load # Load the default bookmarks when starting

Commands

The following commands are available:

Command Description
bookmark create <name> [path] Create a new bookmark.
bookmark remove {name} Remove bookmarks.
bookmark rename <name> <new_name> Rename bookmark.
bookmark clear Remove bookmarks with invalid paths.
bookmark go <name> Go (cd) to bookmark.
bookmark get <name> Get path of bookmark.
bookmark list List bookmarks.
bookmark save [location] Save bookmarks to file.
bookmark load [location] Load bookmarks from file.
bookmark change <name> <new_path> Change bookmark's path.

Completions for bookmarks are available and all commands have a description, as well as their arguments and flags, so usage should be fairly straightforward due to Nushell's incredible completion features.

Usage

Commands that create, delete or modify existing bookmarks operate on a local, per-session, registry. Writing (bookmark save) saves to a local file such that the state of the bookmarks registry can be retrieved later by reading (bookmark load) from a local file.

Commands that have standard output, that is, informational messages reporting on the success of an operation, allow a --silent flag that, when passed, disables such output.

When explicit paths aren't provided, these commands fall back to the default bookmarks file path, which is initially $nu.home-path/.bookmarks. This can be changed by modifying the $env.nu_bookmarks_dir variable before running the bookmarks script. The following config makes bookmarks.nu save to C:/.bookmarks by default:

$env.nu_bookmarks_dir = "C:"
use bookmark
bookmark load

A bookmarks file is a simple text file where each line is a bookmark name and a directory path, separated by a double-colon (::). Therefore, double-colons are disallowed in bookmark names, and commands will give you an error about this if you try to use double-colons when creating or renaming a bookmark.

About

Bookmarking commands for navigation in Nushell.

Topics

Resources

License

Stars

Watchers

Forks

Contributors