GithubHelp home page GithubHelp logo

vjacynycz / dirjump Goto Github PK

View Code? Open in Web Editor NEW

This project forked from imambungo/dirjump

0.0 0.0 0.0 2.15 MB

Easily jump to recently "used" directories with oh-my-zsh's 'd'-like directory history that still saved after exiting the terminal.

License: GNU General Public License v3.0

Shell 100.00%

dirjump's Introduction

dirjump

Easily jump to recently used directories with oh-my-zsh's 'd'-like directory history that still saved after exiting the terminal. A directory is considered to be used if you have opened a file or ran your preferred command in that directory.

Usage

Main Feature

  • Show the list of 10 most recent used directories with d.

  • Jump to any directory in the list by typing the number of the directory in the list. You need to use 0 instead of 10 to jump to the 10th directory.

  • A directory path will be put to the top of the list every time you use v(vim) to edit files or o(xdg-open) to open a file from that directory. Or if you like, every time you visit a directory.

Additional Feature

  • Automatically list all files in the directory you jumped to if it contains 30 or fewer files. You can disable this feature if you like.
  • Home or ~/ is never added to the history (we can just type cd).
  • Shows the last time a path was removed from the history. This information may help you adjust the history size to better suit your need. To change the history size, refer to this section

Dirjump in action

dirjump in action

Personal Preference

You can modify the code to suit your needs. If you follow the installation guide, the script is located in ~/.config/dirjump/dirjump.

Change the main command

You can change the main command from d to another by modifying the code below:

dirjump_command="d"

Alternative command to jump

By default, you can also jump with <main command> <directory number>:

d 8

If you already used any number as aliases, just delete or comment out the code from line 18 to 25.

I don't use Vim

You can make a spesific command trigger dirjump to put your current directory to the directory history by adding the following line to the end of the script:

alias <yourcommand alias>="propose_dir_path && <yourcommand> " # make sure you put a space before the closing double quote

Here's an example to make vsc an alias of code(the command to run VSCode):

alias vsc="propose_dir_path && code "

Always put visited directory to the history

This is not recommended but if you want dirjump to always put visited directory to the history, add the following snippet to the end of the script:

# If using Zsh
if [ -n "$ZSH_VERSION" ]
then
	# Source: https://stackoverflow.com/a/3964198/9157799
	chpwd_functions=(${chpwd_functions[@]} propose_dir_path)
else
	cd()
	{
		builtin cd "$@" # https://unix.stackexchange.com/a/366974/307359
		propose_dir_path
	}
fi

Don't list files after jump

Here, just delete it.

Um... only 10??

There you go.

Installation

  1. Download the script.

     curl --create-dirs -o ~/.config/dirjump/dirjump https://raw.githubusercontent.com/imambungo/dirjump/master/dirjump
    
  2. Source the script to your shell. Don't forget to restart your terminal afterward.

     echo 'source ~/.config/dirjump/dirjump' >> ~/.bashrc
    

    If you use Zsh:

     echo 'source ~/.config/dirjump/dirjump' >> ~/.zshrc
    

Uninstallation

  1. Delete the script and the directory history file.

     rm -rf ~/.config/dirjump
    
  2. Unsource the script from your shell.

     grep -Fxv "source ~/.config/dirjump/dirjump" ~/.bashrc > temp; mv temp ~/.bashrc
    

    If you use Zsh:

     grep -Fxv "source ~/.config/dirjump/dirjump" ~/.zshrc > temp; mv temp ~/.zshrc
                                                     #####
    

Contributing

If you found bugs, typos, wrong grammar, or have any suggestion or question, feel free to create a new issue.

dirjump's People

Contributors

imambungo avatar automationboi avatar usamahjundia avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.