Bash Shortcuts¶
Ctrl + A Go to the beginning of the line you are currently typing on Ctrl + E Go to the end of the line you are currently typing on Ctrl + L Clears the Screen, similar to the clear command Ctrl + U Clears the line before the cursor position. If you are at the end of the line, clears the entire line. Ctrl + H Same as backspace Ctrl + R Let’s you search through previously used commands Ctrl + C Kill whatever you are running Ctrl + D Exit the current shell Ctrl + Z Puts whatever you are running into a suspended background process. fg restores it. Ctrl + W Delete the word before the cursor Ctrl + K Clear the line after the cursor Ctrl + T Swap the last two characters before the cursor Esc + T Swap the last two words before the cursor Alt + F Move cursor forward one word on the current line Alt + B Move cursor backward one word on the current line Tab Auto-complete files and folder names
Grep¶
Use find to discover the appropriate files and then grep to search inside the file:
find . -name '*.tex' -exec grep -n 'color}' '{}' /dev/null \;
Why add /dev/null
? This is to fool grep into thinking more than one file is being processed, at which point it will add the file name to the output.
GNU grep
has -H option instead of using \dev\null
:
find . -name '*.tex' -exec grep -nH 'color}' '{}' \;
Alternatively, use gnu find
's multi-actions-in-one-go ability:
find . -name '*.tex' -exec grep -n 'color}' '{}' +
If using an advanced version of grep
(e.g. on non-embedded Linux or BSD or Mac OS X):
grep -nr --include='*.tex' 'color}'
OpenBSD:
grep -nR --include='*.tex' 'color}'
Music On Console (MOCP)¶
Using MOC
Let’s switch to the most important part of this article — how to actually use play music with MOC :) . First run the program with mocp command. A window with your file system on the left should appear. The right side is reserved for the playlist. Now you can:
ENTER – switch to a folder, start playing the song, etc
‘o’ – play URL (for instance some Internet radio)
‘p’ or space bar – pause playing
‘s’ – stop playing
‘l’ – switch between one and two-column view
‘a’ – add current file to the playlist
‘A’ – add current folder (recursively) to the playlist
‘C’ – clear the playlist
‘q’ – turn the console interface off (MOC server is still running and you can come back by entering mocp again)
‘Q’ – hard power-off MOC
MOC can be also manipulated when the console interface is switched off. Here are some commands that may be useful for that:
‘mocp -S’ – run the MOC server
‘mocp -p’ – start playing the playlist
‘mocp -f’ – switch to the next track on the playlist
‘mocp -r’ – switch to the previous track on the playlist
‘mocp -s’ – stop playing
‘mocp -P’ – pause playing
‘mocp -U’ – resume playing
‘mocp -x’ – kill the server
More options can be obviously found in the MOC manual by entering man mocp.
MOC is a console-based (build on ncurses library) audio player for Linux/BSD. It’s very easy to use, fast and functional so basically it has all the features of a decent player except for a fancy GUI. What is more — it takes a fraction of system resources consumed by most popular GUI players but still plays all popular formats „out-of-the-box”.
Author: Roman Tworkowski
Installation
Installing MOC is trivial. You can either download the sources, compile them and run or get a package specific to your distribution of choice and install it this way.
If you are using Debian or Ubuntu you can use these repositories:
deb http://www.lxtec.de/debarchiv unstable main deb-src http://www.lxtec.de/debarchiv unstable main
Even though MOC is available in the default repos, it’s better to use those from lxtec.de since they are updated more frequently. After adding the lines above to /etc/apt/sources.list file you should run aptitude update && aptitude install moc to get the latest version from the repo.
If you are a hardcore player, use the MOC Subversion repository svn://daper.net/moc/trunk to get the creeping edge version of software. Configuration
In the first place, MOC doesn’t require any special configuration. Still if you would like to play with the options feel free to copy the example config file from /usr/share/doc/moc/examples/ to your home folder in ~/.moc. Easy way to do it is by using this shell command: zcat /usr/share/doc/moc/examples/config.example.gz > ~/.moc/config. Then just edit the file manually with your most hated editor like vim. The options are a no-brainer so I won’t continue explaining them here. Consult the manual if you encounter any problems.
MOC-specific features
MOC may be a bit different than any other audio player you know. These differences are in plus in my opinion ;-) .
First, after when you select a song from a folder, MOC will keep playing the next song in the same folder when the selected one is over. Secondly, MOC automatically remembers the playlist on exit and reads it when you next time run it. Third, thanks to pre-caching system, there are no annoying breaks between the played tracks. It is especially noticeable when playing an audio CD. Final tips
Finally I have a few tips from an experienced MOC user that may help you enjoy using MOC even more ;-) .
Yes, it’s themeable too! The default MOC theme is… well pretty disgusting. For black terminals and those with transparency on the ‘transparent-background’ theme looks much better. You can set it in ~/.moc/config. If none of the themes fits your needs, no problem! Just download one from somewhere in the Internet and set it to default in the config file. Some MOC themes are located in /usr/share/moc/themes.
In case you don’t need another window on your crowded desktop, you can use ‘q’ to turn the MOC interface off and then run it again if you need the control. The tracks will keep playing anyway thanks to the build-in sound server.
I hope with this little article I made you want MOC on your desktop. If so, please feel free to leave a comment about your experience with MOC. More on MOC
MOC official website
Some MOC screenshots
OCRprogs¶
gocr (CLI) - pnm/pbm/pgm/ppm ocrad - pbm/pgm ocrfeeder (GTK) gocr-tk - tk interface to gocr gscan2pdf ocrodjvu
PyMazon¶
Command Line Interface
To download to current directory:
$ pymazon -c /path/to/amz/file/foo.amz
To download to alternate directory:
$ pymazon -c -d /path/to/save/dir/ /path/to/amz/file/foo.amz
Archive handling¶
CBZ¶
zip filename.cbz *.jpg
Dice¶
Dice roller
e.g. roll 2d8 + 1d6 + 3
roll
Usage
roll [OPTION] expression
Options
-p, --positive allow only positive results
-h, --help show this help screen
-s, --sum-series show the sum of roll series
-v, --verbose increase verbosity
--version prints the program version and exits
Expressions
Expressions are in dice notation (also known as dice algebra, common dice notation or RPG dice notation).
Die rolls are expressed in the form NdX
or NDX
where N
is the number of dices (1 if omitted) and X
the number of dice faces.
If the final number is omitted, it is assumed to be a six.
To this basic notation, an additive modifier can be appended, yielding expressions of the form, NdX+C
. The plus can be replaced by a minus sign (-) for subtraction. C
is a number to be added or subtracted from the final total.
Percentile dice (d%)
Often, the variable X
in the above notation will be %
. Although a 100-sided die does exist, it is both more common and more uniformly random to use a combination of two ten-sided dice known as percentile dice, where one die represents tens and the other units. A roll of two zeroes means 100.
If you want to roll a single 100-sided die use the d100
notation.
Fudge dice (dF or df)
The Fudge role-playing game system uses customized Fudge dice which have an equal number of plus, minus and blank sides.
Multipliers
In some games, the above notation is expanded to allow for a multiplier, as in NdXxC
or CxNdX
, where x
or *
denotes multiplication (can be replaced by /
for division) and C
is a natural number.
Results are rounded up.
Reroll filters
It is possible to specify restrictions on dice rolls telling which values to keep and which values to discard by putting a filter after the dice. If a value is to be discarded the dice is re-rolled until the result is valid value. You can specify to keep only values bigger (>
), bigger or equal (>=
), smaller (<
), smaller or equal (<=
) or different (!=
) from a given number.
The comparator is specified right after the the die specification (e.g., 1D6>2
).
Selective results
It is possible to keep only the M highest or lowest dices with the following notation:
NdXhM
: rollN
dices withX
sides and keep the highestM
results (M
must be less or equalN
)NdXlM
: rollN
dices withX
sides and keep the lowestM
results (M
must be less or equalN
)
Series and repetitions
It is possible to concatenate top-level expressions with a comma (expression, expression
) and to repeat the execution of an expression or a set of expressions by using a counter and curly brackets (N{ expression}
)
Examples
3d6 |
rolls 3 6-sided dices and sums the results (can be abbreviated with 3d) |
1d8 + 3 |
rolls 1 8-sided die and adds 3 (can be abbreviated by d8+3) |
d% |
rolls 2 10-sided dices: one represents the tens and the other units |
1d6x5 |
rolls 1 6-sided dice and multiplies the result by 5 |
1d6 / 2 |
rolls 1 6-sided dice and divides the result by 2 (1d3) |
4d6h3 |
rolls 4 6-sided dices and keeps the 3 highest results |
6{3d6} |
rolls 3d6 6 times |
1d6>2 |
rolls 1d6 until the result is bigger than 2 |
4dF |
rolls 4 Fudge dices |
Dice algebra grammar
Grammar in EBNF form:
expression := term { "+" term | "-" term } .
term := number | factor [ ("*"|"/") number |
number ("*"|"/") factor | "(" expression ")" .
factor := number FilteredDice [ ("h"|"H"|"l"|"L") number ] | FilteredDice .
FilteredDice := dice | dice (">"|">="|"<"|"<="|"!=") number .
dice := "d" | "D" | "w" | "W" | "t" | "T" [ number | "%" | "F" | "f" ] .
rolldice