Skip to content

aiya000/sh-bookmark-hereis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔖 sh-bookmark-hereis

**The Smallest**

**No Rich**

Bookmark Utils

example

$ cd utils for your shell (bash, zsh, and others compatible shells)

🚀 Installation

  1. git clone this repository (assuming you have ~/bin in your $PATH)
$ git clone sh-bookmark-hereis ~/bin
  1. Add below line to your shell config file (e.g. ~/.zshrc, ~/.bashrc)
$ echo 'source ~/bin/sh-bookmark-hereis/init.sh' >> ~/.zshrc
  1. Restart your shell or run $ source ~/.zshrc ($ source ~/.bashrc)

💡 Usage

✨ Adding a bookmark

$ cd ~/foo/your-precious-project
$ hereis

Then, below alias and varible are added to your $HEREIS_PLACES_FILE file :D

alias hereis-your-precious-project='cd "/home/your_name/foo/your-precious-project"'
hereis_your_preciouse_project="/home/your_name/foo/your-precious-project"

About $HEREIS_PLACES_FILE environment variable and the prefix hereis- (hereis_), see below 'Configurations' section. It defaults to ~/.hereis_places.

✍️ Custom Bookmark Name

You can specify a custom name for the bookmark:

$ cd ~/foo/your-precious-project
$ hereis current-project

Then, bellow alias and varible are added.

alias hereis-current-project='cd "/home/your_name/foo/your-precious-project"'
hereis_current_project="/home/your_name/foo/your-precious-project"

📖 Viewing bookmarks

Use hereis-show-paths command to view all registered bookmarks:

$ hereis-show-paths
paths (variables):
  hereis_your_precious_project: /home/your_name/foo/your-precious-project
  hereis_current_project: /home/your_name/foo/your-precious-project

aliases:
  alias hereis-your-precious-project='cd "/home/your_name/foo/your-precious-project"'
  alias hereis-current-project='cd "/home/your_name/foo/your-precious-project"'

This shows both the shell variables and aliases that were created for easy access to your bookmarked directories.

✏️ Editing bookmarks

Use hereis-edit command to manually edit your bookmarks file:

$ hereis-edit
hereis> Reloaded paths

This opens $HEREIS_PLACES_FILE in your default editor ($EDITOR). Also after you save and close the editor, it automatically reloads the places by hereis-reload (See below section for hereis-reload)..

🔄 Reloading bookmarks

Use hereis-reload to reload your bookmarks without restarting the shell:

$ hereis-reload
hereis> Reloaded paths

This re-sources your $HEREIS_PLACES_FILE and makes any new bookmarks or changes available in your current shell session.

⚙️ Configurations

🌳 Environment Variables

You can customize the behavior by setting these environment variables before sourcing init.sh:

📁 $HEREIS_PLACES_FILE

Specifies the file where bookmarks are stored.

  • Default: ~/.hereis_places
  • Example: export HEREIS_PLACES_FILE=~/.config/hereis/places

🏷️ HEREIS_ALIAS_PREFIX

Sets the prefix for generated aliases and variable names.

  • Default: hereis-
    • (For aliases. For variables, - suffix replaced to _ automatically, like hereis_)
  • Example: export HEREIS_ALIAS_PREFIX='p-'
    • My recommendation is p- ('p' of 'places') for shorthanding :D

When above example set, hereis project would create the alias p-project instead of hereis-project.

🛠️ Manual Configuration

You can also set these variables after installation by adding them to your shell configuration file (e.g., ~/.zshrc, ~/.bashrc):

# Custom configuration
export HEREIS_PLACES_FILE=~/.my-places
export HEREIS_ALIAS_PREFIX='jump-'

# Load sh-bookmark-hereis
source ~/bin/sh-bookmark-hereis/init.sh

📜 init.sh

The init.sh file is the main entry point that:

  1. Sets default values for HEREIS_ALIAS_PREFIX (if not already set)
  2. Sets default values for HEREIS_PLACES_FILE (if not already set)
  3. Sources your existing bookmarks file to make aliases and variables available

You need to source this file in your shell configuration to enable sh-bookmark-hereis functionality.

About

**The Smallest** **No Rich** bookmarking utility commands implementations for your shell (sh, bash, zsh and others compatible)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages