Posts Tagged ‘bash’
I came across a new blog (seems to have come on-line in March) http://www.epoxyjournal.com. One of the entries was about how to clear command history. Everyone has inadvertently pasted or typed something into the wrong shell. Sometimes its worthwhile to clean up after yourself and sometimes its not. I figured I would offer a suggestion for the times you want to avoid having your embarrassing moments in your ~/.bash_history.
Instead of blowing away your entire current buffer with history -c you can redirect it to another file, flush the buffer to the file, clean it up then append it to your ~/.bash_history. Sure its more work then abandoning your history but insert Godwin’s Law.
So it might look something like this.
$ echo some long one liner you want to preserver $ echo something embarrassing $ export HISTFILE=~/tmphistfile $ history -a $ grep -v embarrassing ~/tmphistfile >> ~/.bash_history # re-point your history file to the right one, or just exit the shell
Matt Simmons thought a little oops utility would be nice. So here is my shoot from the hip attempt, haven’t extensively tested it but I think it works.
#!/bin/bash # wipe your history of lines that match the input # Usage: oops <embarrassing string> TEMPHIST=$(mktemp) export HISTFILE=$TEMPHIST history -a grep -v $1 $TEMPHIST >> ~/.bash_history history -c rm $TEMPHIST HISTFILE=~/.bash_history history -r
Note, there is a short story before the main course.
I recently had a customer leave. It’s never good to lose a customer. They left not because of any service issues but because its hard for them to understand that I am not a web designer. I provided hosting service for them, and I tried to make it clear that they should find a web desinger and someone to maintain their site because that is not something I specialize in or have any interest in doing. At any rate this of course leads to them finding a designer who wants to move their site to some other host. I have no problems with that whatever makes the maintainer happy since he is the one (more…)
Some projects have production code that runs off of a git cloned repository. There may be a case in which you want to notify others when that clone pulls. It is a pretty easy feat with gits post-merge hook. The post-merge hook will run after a merge (think git pull). All you have to do it create a project/.git/hooks/post-merge shell script and chmod +x it. Next time you pull successfully that script will run. Here is an example.
#!/bin/bash
TEMPLOG=$(mktemp)
echo "Sending email notification of update"
git log --reverse --no-merges --stat @{1}.. < $TEMPLOG
sendEmail -u "Production code update notification" -t recipient@domain.com < $TEMPLOG
rm $TEMPLOG
Bonnie is a great tool to use to benchmark your file system. Just a quick tip on using bonnie. (more…)
Text processing is fun. Well, fun if you like to beat your head against a wall. Most of the time I just string a few things together to get whatever I am doing done. Its much better to find the shortest way to do something, it spawns less processes, is more efficient and generally a good idea. So if you have ever wanted to match a string from some given output and only print the preceding line here you go. (more…)

Identica
Twitter
LinkedIn