Code Monkey home page Code Monkey logo

mega_pwd's Introduction

mega_pwd

Dynamically shorten directory names. Intended for use as part of your $PS1.

How it works

The current working path is split into folders. Each of these folders is then assigned a weight. This weight determines the maximum number of characters that can be used to print that folder. The default algorithm to assign a weight is

y = x^0.5

which means that the closer the folder is to the current working directory (and the higher the x), the more weight it has. There are currently 5 different algorithms defined for computing the weight, which can be readily swapped out.

Demo

The following demo shows how the script performs when navigating down 15 directories. Any files under $HOME are prefixed with a tilde(~). The entire time, the pwd string is below the specified cap of 30 characters. Demo Image

The other functions are shown below for the same folder:

constant_func_integral, y=1, (medium->medium)

[~/dv/sc/ats/app/cnt/cnc/my_/dem/complete]$ 

linear_func_integral, y=x, (low->high)

[~/d/s/at/ap/cnt/cncr/my_c/demo/complete]$ 

parabolic_func_integral, y=x^2, (high->low->high)

[~/dvlpmn/sch/a/a/c/c/my_/demo/complete]$ 

sin_func_integral, y=sin(x), (low->high->low->high->low->high)

[~/dv/schdl/at/a/cntr/cnc/m/demo/complete]$ 

cubic_func_integral, y=x^3, (low->high)

[~////a/cn/cncr/my_cnc/demo/complete]$ 

LICENSE

GNU Public License. See LICENSE.

How to set up

  1. Clone this repo, (git clone https://github.com/eraether/mega_pwd.git)

  2. Add source /path/to/repo/example_prompt to your ~/.profile

  3. That's it!

mega_pwd's People

Contributors

eraether avatar

Watchers

 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.