Difference between revisions of "Cdr"
(Trying displattitle...) |
(updating project category from TODO to Done...) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:cdr}} | {{DISPLAYTITLE:cdr}} | ||
− | + | 'cdr' is short for 'cd regex'. cdr is the ProgClub regular expression directory changing software. That's the software that allows you to change directory from your terminal by specifying a regular expression for the directory(s) you want to go to. For other projects see [[projects]]. | |
− | cdr is the ProgClub regular expression directory changing software. That's the software that allows you to change directory from your terminal by specifying a regular expression for the directory(s) you want to go to. For other projects see [[projects]]. | ||
= Status = | = Status = | ||
Line 21: | Line 20: | ||
* /var/backup/sub/amanda/2014-12-01/ | * /var/backup/sub/amanda/2014-12-01/ | ||
* /var/backup/sub/amanda/2014-12-02/ | * /var/backup/sub/amanda/2014-12-02/ | ||
− | |||
* /var/backup/sub/charity/2014-11-06/ | * /var/backup/sub/charity/2014-11-06/ | ||
* /var/backup/sub/charity/2014-11-07/ | * /var/backup/sub/charity/2014-11-07/ | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
* /var/backup/sub/condor/2014-11-26/ | * /var/backup/sub/condor/2014-11-26/ | ||
* /var/backup/sub/condor/2014-11-27/ | * /var/backup/sub/condor/2014-11-27/ | ||
− | |||
− | |||
− | |||
− | |||
And so on. I wanted to get a list like the above from the command line. So I created this cdr utility. The above list was generated with this cdr command: | And so on. I wanted to get a list like the above from the command line. So I created this cdr utility. The above list was generated with this cdr command: | ||
Line 96: | Line 83: | ||
The cdr command is the work horse command. It takes two arguments: | The cdr command is the work horse command. It takes two arguments: | ||
− | + | # the cdr command | |
− | + | # the path regular expression | |
The command can be one of: | The command can be one of: | ||
Line 134: | Line 121: | ||
The software is comprised of a PHP shell script and some BASH aliases and functions. | The software is comprised of a PHP shell script and some BASH aliases and functions. | ||
− | The PHP shell script is [https://www.progclub.org/pcrepo/cdr/branches/0.1/bin/cdr.php bin/cdr.php]. The BASH aliases/functions are in [https://www.progclub.org/pcrepo/cdr/branches/0.1/etc/bash_aliases etc/bash_aliases]. | + | The PHP shell script is [https://www.progclub.org/pcrepo/cdr/branches/0.1/bin/cdr.php bin/cdr.php]. The BASH aliases/functions are in [https://www.progclub.org/pcrepo/cdr/branches/0.1/etc/bash_aliases.sh etc/bash_aliases.sh]. |
+ | |||
+ | See [https://www.progclub.org/pcrepo/cdr/branches/0.1/dev/test.sh dev/test.sh] for test cases. | ||
= Notes = | = Notes = | ||
Line 161: | Line 150: | ||
Edit your ~/.bash_aliases file and source the functions/aliases: | Edit your ~/.bash_aliases file and source the functions/aliases: | ||
− | . /srv/cdr/0.1/etc/bash_aliases | + | . /srv/cdr/0.1/etc/bash_aliases.sh |
Then open a new terminal and see that things seem to be working with a command such as: | Then open a new terminal and see that things seem to be working with a command such as: | ||
Line 180: | Line 169: | ||
= Tasks = | = Tasks = | ||
+ | |||
+ | [[Category:Done]] | ||
== TODO == | == TODO == | ||
Line 186: | Line 177: | ||
N/A. | N/A. | ||
− | |||
− | |||
== Done == | == Done == |
Latest revision as of 03:28, 9 May 2016
'cdr' is short for 'cd regex'. cdr is the ProgClub regular expression directory changing software. That's the software that allows you to change directory from your terminal by specifying a regular expression for the directory(s) you want to go to. For other projects see projects.
Status
Version 0.1 released!
Motivation
Why this software? Good question!
I have a backup script which creates directories for each computer in /var/backup/sub, for example:
- /var/backup/sub/amanda/
- /var/backup/sub/charity/
- /var/backup/sub/condor/
And so on. Within each computer directory are a number of other directories with the date of the backup, for example:
- /var/backup/sub/amanda/2014-12-01/
- /var/backup/sub/amanda/2014-12-02/
- /var/backup/sub/charity/2014-11-06/
- /var/backup/sub/charity/2014-11-07/
- /var/backup/sub/condor/2014-11-26/
- /var/backup/sub/condor/2014-11-27/
And so on. I wanted to get a list like the above from the command line. So I created this cdr utility. The above list was generated with this cdr command:
$ cdl '/var/backup$/sub/.*/[\\d\\-]+'
Administration
Contributors
Members who have contributed to this project. Newest on top.
All contributors have agreed to the terms of the Contributor License Agreement. This excludes any upstream contributors who tend to have different administrative frameworks.
Copyright
Copyright 2014, Contributors.
License
Licensed under the GPL.
Resources
Downloads
There are no downloads for this project.
Source code
The repository can be browsed online:
https://www.progclub.org/pcrepo/cdr/branches
The latest stable released versions of the code are available from:
https://www.progclub.org/svn/pcrepo/cdr/tags/latest
Or if you want the latest versions for development purposes:
https://www.progclub.org/svn/pcrepo/cdr/branches
Links
- Read about regular expressions on Wikipedia.
Specifications
Functional specification
The functional specification describes what the project does.
The software provides the following set of commands:
cdr
The cdr command is the work horse command. It takes two arguments:
- the cdr command
- the path regular expression
The command can be one of:
- next: iterate through all matches
- list: list all matches
- xarg: list all matches delimited by a null byte, appropriate for passing to xargs -0
- count: list the number of matches
Usually the cdr command is invoked by one of the shorter commands that follow:
cdn
The cdn command stands for 'cdr next'. It will iteratively move you through all matching directories. In bash you type:
cdn '/path/to/match'
and you will be cd'ed to the first match. Type the command again (or press the up arrow) and you will be cd'ed to the next match. And so on.
cdl
The cdl command stands for 'cdr list'. It will list all matching directories.
cdx
The cdx command stands for 'cdr xarg'. It will list all matching directories delimited by a null byte. This output is suitable for input into xargs -0.
cdc
The cdc command stands for 'cdr count'. It prints out the number of matching directories.
Technical specification
The technical specification describes how the project works.
The software is comprised of a PHP shell script and some BASH aliases and functions.
The PHP shell script is bin/cdr.php. The BASH aliases/functions are in etc/bash_aliases.sh.
See dev/test.sh for test cases.
Notes
Notes for implementers
If you are interested in using this software here's what you need to know:
Make sure you have PHP5 CLI installed. On Debian/Ubuntu that's:
apt-get install php5-cli
Then check out the latest versions from Subversion, e.g.:
cd /srv svn co https://www.progclub.org/svn/pcrepo/cdr/tags/latest cdr
Make sure the cdr.php script is executable:
chmod +x /srv/cdr/0.1/bin/cdr.php
Create a symlink for the 'cdr' command in /usr/local/bin:
ln -s /srv/cdr/0.1/bin/cdr.php /usr/local/bin/cdr
Edit your ~/.bash_aliases file and source the functions/aliases:
. /srv/cdr/0.1/etc/bash_aliases.sh
Then open a new terminal and see that things seem to be working with a command such as:
cdl '/.*'
That command should list all the directories in / (root).
Notes for developers
If you're looking to set up a development environment for this project here's what you need to know:
See source code for notes on where to get a development branch.
If you're forking this software add your fork version to the CDR_VERSION constant in bin/cdr.php, e.g.:
const CDR_VERSION='0.1.3-[your fork version]';
Tasks
TODO
Things to do, in rough order of priority:
N/A.
Done
Stuff that's done. Latest stuff on top.