Posted April 16, 2008
The command to find the list of commands that you use the most is:
history | awk '{print $2}' | sort | uniq -c | sort -rn | head
I like this version because it has uses a few simple and useful commands.
My list:
11398 ls
6724 cd
5200 vim
2330 sudo
1462 mutt
1131 perl
1122 mplayer
1036 svk
825 mpc
795 lt
The lt command is a shell alias for ls -lt. Other people don't have a
editor in this list. This probably occurs because they use emacs which works
better when it is open a long time. I use vim that way sometimes, but most of
the time I use it for small and fast changes.
The number are this high because my history limit is higher than the default.
You can use the following lines to increase the limit.
export HISTFILESIZE=1000000000
export HISTSIZE=1000000
shopt -s histappend
export PROMPT_COMMAND='history -a'
You should take a look at the bash reference to find out what everything does.
Posted April 10, 2008
When I first posted the simple regex code I thought that it contained no
errors. But when I tried it a few days after that with a few simple testcases
(which I hadn't considered in the test code) it failed.
ok $ match "world$" "world"
ok $ match "world$" " world"
ok $ match "world" "hello world"
The first testcase worked. The other two didn't, but they should have. After a
bit of inspection with the trace function in Debug.Trace I found out that
the function couldn't move past the first character. I thought matchhere would
take care of that, but it didn't.
The change that is needed was in match. These lines have the error.
match reg s@(x:xs) = if matchhere reg s
then True
else matchhere reg xs
The function only tried to match at the first and second position.
match reg s@(x:xs) = if matchhere reg s
then True
else match reg xs
By changing matchhere to match, now matchhere will be called on each
character of the string. Because this way the end of the string can be reached,
I have to the two lines to check for the end of the string and the regex.
match [] _ = True
match _ [] = False
It seems that the code works now like it should.