Linux Blog

Linux History Command

Filed under: General Linux,Linux Software — TheLinuxBlog.com at 5:00 am on Wednesday, November 17, 2010

linux find command

History is great. How does the saying go?

“Those who forget about history are doomed to repeat it?”

If that’s the saying I think it is more fitting to say that for those who forget the Linux History Command are doomed to repeat typing. A lot. Seriously, the history command can help you remember the exact Linux find command with the intricate search options you typed a while ago. It could help you open up your x2x or x2vnc sessions after a reboot. Who knows what you’ll use it for. All this comes at a little cost, you’ll have to know how to use it.

(Read on …)

Reattach Screen Script

Filed under: Shell Script Sundays — TheLinuxBlog.com at 2:02 pm on Sunday, April 12, 2009

A friend of mine who happens to be an avid screen user sent me this snippet below:

### Reattach to a screen if one exists ###
if [[ $TERM != 'screen' ]] ; then
if [[ `screen -list | grep -v "No" | awk '$2 { print }' | wc -l` == 0 ]] ; then
screen
else
screen -dr
fi
fi

What this handy snippet does is looks for a screen session, if it finds one it detaches the running screen, and reattaches it(-dr) if it isn’t lucky enough to find one, then it just starts a session up for you. Its rather handy to put in your .bashrc file to auto launch a screen session. The only thing I have modified for my use is replacing -dr for -x to enable me to reattach the screen without detaching the session I may have had open on another terminal. It works pretty well, although when you open a new “screen” CTRL-a + c, the tab doesn’t show up on the other sessions until you change to it, or cycle through them. It isn’t a big deal and could even be a local configuration issue. Anyway, enjoy this snippet and as always let me know if you found it useful.

Logging Sessions to Twitter

Filed under: Linux Software — TheLinuxBlog.com at 12:01 am on Wednesday, August 20, 2008

If you follow me on Twitter you would know I asked everyone if there was anything that they wanted me to write about. @Ben_Marvin responded and asked about logging the commands you type to Twitter.At first, I thought that this could be done with history, which it probably can be, but does everything you type really have to be echo’ed to Twitter? I don’t think that you’d have many friends, Twitter would probably hate you and you’d most likely hit your maximum requests per hour pretty quickly.The Script command is another option, and this works quite well for this purpose. Read the script man page to find out more about this program. It basically (when ran) takes the I/O from your terminal and logs it to a file. Its a very handy utility.So, how do we get this data into Twitter? First of all, Twitter doesn’t allow very long posts so echoing out the data that the commands you type is not really practical. The best way to do it is to use script to log the session, exit the session and grep for the “]0\;” string for stuff you typed & not the responses.Here is the code:

script; grep ]0\; typescript 

You can then copy and paste it to your favorite Twitter application or pipe it to a scrubbing script to remove the formatting and do the correct HTML stuff, then post it via the http interface. Either way, it can be done even though I don’t think it really should.

Yakuake – The Nifty Terminal

Filed under: General Linux,Linux Software — TheLinuxBlog.com at 12:47 pm on Friday, July 25, 2008

Yakuake – “Pronunciation Key: yuh-kweyk”

Yakuake is a terminal emulator for KDE
“Why do we need another terminal emulator?”
I hear you ask.

Well, the Yakuake terminal emulator resembles the terminal from Quake (hence the name), except the only thing that gets owned when you run Yakuake is your to-do list.

Have you ever been fragged in Quake because you hit the Tilda key by accident?
Ever used this to your advantage while playing two player by pressing your opponents tilda key?

Have no idea what I’m talking about?
envision a terminal that magically pops up when you press a shortcut, hides when your not using it but retains the output / processes and does not show up in the task bar.

Sure there are old school ways of achieving the same thing, but Yakuake is convenient. It is based on Kommander so its highly configurable and customizable but it works right out of the package.

I use it on most of my machines and for quick tasks I find myself using a regular xterm less. If you want a quick easy access to a terminal I’d recommend trying Yakuake out, take a look at all of the keyboard shortcuts and see if there is any way you can make it work better for you.

I have my keyboard shortcuts set up so I can add new sessions, close sessions, rename sessions, move sessions and resize the terminal. It works great with the switch to session shortcuts that I also set up.

Its in the Fedora repositories, I’m sure its included in Debians 18,000 or so packages and probably Gentoo’s too, so give it a shot!

I’ll see what I can do about a video tutorial in the future to demonstrate the power of Yakuake.