Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A bash script for managing dirs, pushd, and popd across terminals and systems.

License

NotificationsYou must be signed in to change notification settings

karlredman/dirp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A bash script for managing dirs, pushd, and popd across terminals and systems.

Author:Karl N. Redman

dirp provides an easy way to traverse and store complex and lengthy directory locations for current and future use in groups. dirp allows you to leverage the power ofdirs,pushd andpopd on a per group basis. With dirp you can share your command line paths between terminals easily. And, through the use ofgit andssh, it is a method of synchronizing your command line path groups/lists across different computers.

Current Features:

See the same list of features with exampleshere

  • Does not interfere with dirs/pushd/popd normal operations.
  • List and select directories managed bydirs in alternating colors in groups.
  • Simplified directory traversal and usage.
  • Simplified aliases (optional).
  • CLI Menu driven interface (via bash select).
  • Easily switch between directory groups (i.e. projects).
  • Automatically sorts directory listings.
    • Versioned-text aware.
    • Alphanumeric.
    • Handles directory names that use spaces.
  • New terminals automatically load the latest directory group.
  • Create and delete directory groups easily.
  • Colors and application behavior managed by environment variables.
  • Short list of commands.
  • Command tips (disabled via environment variable).
  • Synchronize across multiple systems:

Screenshot:

dirp animated gif

asciinema: Installation and Demo (2 min)

asciicast

Installation:

See configuration for more details -here's the quick setup/default stuff

Note: It is imperative that this operates viasource <file path>/dirp.bash from your.bashrc (or equivalent). The reason for this is thatdirp,pushd, andpopd are very strictly "shell scoped". This is one of the main reasons people have so many questions about these utilities, why these utilities are so terribly underused, and why many programmers and admins seek other utilities.

  • Note requirements:
    • Bash >=v4.0
    • Linux: (tested only on Linux)
  1. Clone the project
git clone https://github.com/karlredman/dirp.git
  1. Create a project management directory (small files, per project, that store the absolute paths of files you want to cache)
mkdir -p $HOME/dirlists
  1. Add the following to your.bashrc (or equivalent) file -toward the end...ish
source file_path/dirp.bash
  1. (optionally) Change configurables as needed/desired (see 'Configuration' below)

  2. start a new terminal or source your.bashrc

source ~/.bashrc

Command Usage:

commanddescription
dirpmain menu interface
dirppchoose dirp project
dirpllist directories in current project
d(alias enabled by default) same as dirpl
dirpupushd current directory and save to project
dirpo <index>popd the index from dirpl
dirpssave current list to selected project

dirp Menu Reference:

item #namedescription
1load projectload a project from list (same asdirpl)
2create projectcreate a new project file (same asdirpc)
3save to projectsave current project list to another project from list (same asdirps)
4delete projectdelete project from list
5list directorieslist directories in current list (same asdiprl)
6add directoryaddcwd or specified directory to current list (same asdirpu)
7delete directoryremove a directory in current project from a selection list (same asdirpo)
10show configurationprint current dirp settings
11Helpshow help message
12Quitquit the dirp menu

Extended Configuration:

TL;DR

The extended Configuration information below provides information for fine tuning and customization and overriding defaults.

Configuration Variables:

  • DIRP_LATEST_FILE

    • absolute path of file containing the name of the latest project managed by dirp
    • if set to 'NONE' then dirp_auto returns without reading a file. i.e. no questions or loading of previous project.
      • this is useful if you start tmux/tmuxinator with apre: DIRP_LATEST_FILE='NONE';
  • DIRP_PROJECTS_DIR

    • absolute path of the directory repository of project files -that contain directory lists
      • file names are equal to project name
      • files contain directory listings managed by dirp
  • DIRP_LIST_COLOR1

    • the first color for project directory file listings
  • DIRP_LIST_COLOR2

    • the second color for project directory file listings
  • DIRP_EXPERT [true|false]

    • turn off tips and 'Are you sure?' prompts and messages (mostly)
      • honestly I still have stuff likerm -i <blah> in the code that is called so it's still kinda idiot (me) proof-ish
  • DIRP_USEALIASES_SUITE [true|false]

    • Includes aliases for shortcuts that bypass the menu system -you can turn this off if you want.
    • i.e. addsalias d=dirp_listColorized
  • DIRP_USEALIASES_DIRNUMS [true|false]

    • This is HIGHLY CONTROVERSIAL for a lot of CLI peoples. Leaving this on (default) creates aliases for numbers 1-30 that will help you navigate directories relative todirs. Look, it might seem simple and trivial but it's kind of a religious thing for some people (not me). I'm not judging and I'm providing the builtin utility if you want to use it. For what it's worth, I do use these aliases.

Configuration Defaults

(change as you like -add beforesouce <path>/dirp.bash in your.bashrc)

DIRP_LATEST_FILE="/tmp/dirp_latest"DIRP_PROJECTS_DIR="$HOME/dirlists"DIRP_LIST_COLOR1='\e[0;33m'DIRP_LIST_COLOR2='\e[0;36m'DIRP_EXPERT=falseDIRP_USEALIASES_SUITE=trueDIRP_USEALIASES_DIRNUMS=true

Command line usable functions and aliases:

  • 1-30 (numbers)
    • Merely performs a change directory relative todirs indexes (sans the current working directory -because that would be silly)
    • Note: The philosophy behind this is hinted in the use cases. The bash builtin functiondirs -v provides indexes that can be used by specifying~<index> which can be used for copying, moving, etc. So these aliases literally substitute change directory commands that correspond to thed function output (which is actually the same thing asdirs -v (but colorized) above. so1<enter> on the command line is the same as typingcd ~1 -which corresponds to the first directory listing in thedirs directory stack. Some people HATE this idea. Others (me) like it. meh.

Color Configuration References

Here's some references that might help out if you want to play around with colors and underlines and stuffs:

Contributing:

Please read:dirp/CONTRIBUTING.md at master · karlredman/dirp

License:

This project is hereby copy written by Karl N. Redman (November 29, 2017). Any use of this intellectual property is permitted insofar as such usage conforms to the MIT license included within the project. All rights reserved. Please refer to:dirp/LICENSE at master · karlredman/dirp

About

A bash script for managing dirs, pushd, and popd across terminals and systems.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp