jalanb / cde Goto Github PK
View Code? Open in Web Editor NEWcde extends cd, historically
License: MIT License
cde extends cd, historically
License: MIT License
Add an option, --logging, which shows user a (high-level) description of why directory was chosen.
If used with "-" (previous directory), then show why last directory was chosen
Suppose I do
$ kd /usr/local/bin
$ ks /usr/bin
And now I want to do
$ kd -o bin
by which I mean - choose the "...bin" from history and cd there. That will always find more than 1 possibility, and choose the most recent, which will be /usr/bin. Actually I mean /usr/local/bin. At present I need to list all history, copy the full path, and "kd ". But, listing the path assigns a unique number to each path, so I should be able to use that number to
$ kd -o 2
which would bring me to the 2nd path on the list, which would be the the desired /usr/local/bin in the example
kd is mature enough to deserve a version number.
AFAICT it is currently at version 0.2.0, as 0.1 was basic functionality, and 0.2 added history.
Add an option to purge any items from history which are
*
clears the history completelyI've not been keeping up with test results in all ways of running them, hence:
$ kd -t
**********************************************************************
File "/Users/user/kd/kd.tests", line 75, in kd.tests
Failed example:
kd.find_directory('/usr', ['li'])
Expected:
Traceback (most recent call last):
...
TryAgain: Too many possiblities
0: /usr/lib
1: /usr/libexec
Got:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/doctest.py", line 1254, in __run
compileflags, 1) in test.globs
File "<doctest kd.tests[23]>", line 1, in <module>
kd.find_directory('/usr', ['li'])
File "/Users/user/kd/kd.py", line 277, in find_directory
path_to_prefix = find_under_directory(path_to_item, prefixes)
File "/Users/user/kd/kd.py", line 189, in find_under_directory
raise TryAgain('Too many possiblities\n\t%s' % as_menu_string(possibles))
TryAgain: Too many possiblities
0: /usr/lib
1: /usr/libexec
kd should use similar criteria for searching through possibilities for
These will be similar, not identical, as (e.g.) the former might include files, the latter won't. But they should be consistent - if one search values names over globs, then the other should too.
Create sub-directories for code, test, docs
Consider standard root-level files, such as README, COPYING, INSTALL
When the arguments do not allow kd to choose one directory it stops, showing the user the list of possible choices, e.g.
$ c /tmp bi
Error: Too many possiblities
/tmp/bib
/tmp/bin
That list of choices should be enumerated, e.g.
$ c /tmp bi
Please be more specific
1: /tmp/bib
2: /tmp/bin
User should then be able to repeat the command and choose one (i.e. hit <up arrow>, <number>, <return>). kd now goes to the chosen directory.
$ c /tmp bi 2
cd /tmp/bin
This makes the list of ambiguous choices look like the history list, hence same facility should be available from the history list: user says
$ kd -l
to show the list, which are shown numbered. user then hits <up arrow>, <number>, <return>, command now looks like
$ kd -l 5
so kd goes to 5th item in history list
History current shows time as (e.g.) "3 hours 4 minutes ago"
User should have the option to use other formats, e.g. "Fri 13 Sep 2013 00:11:53 IST".
Formats could be those offered by the date command (i.e. strptime)
kd is now big enough to need better documentation that just a docstring and a readme file.
Suggested
At present kd requires a "super user" to download and install.
Consider available installation strategies for other users:
The -o option allows one to choose an "old" path (one from history). Hence it should be followed by a string to choose, so this is expected (when looking for "stuff" in history)
$ kd -o stuff
And this should be an error:
$ kd -o
In practice the latter actually uses $HOME, which is often in the history, so it goes home. It should be an error
My current version of frecency is simply:
Sort by number of times used, then by time since last use
This is very much a first draft and for example, leads to problems when moving a directory which was often used - the old place stays high in rankings till the new is used more often.
See also
Quick hack before a deeper strategy: allow user to edit the history file. Currently it is plain text, so editable, but not the most user-friendly format (e.g. epoch times)
https://app.leanboard.io/board/c162cc7d-0d36-4b9c-b5df-0507c3e74b5f
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.