Showing posts with label command line. Show all posts
Showing posts with label command line. Show all posts

Friday, April 16, 2010

Stop the Corruption! - Putty and Screen

I use putty to make ssh connections to my home server when I'm forced to use MS Windows, such as when I'm at work. The first thing I do after connecting is start up screen, which opens several pre-assigned applications in "tabs". Putty's default settings seem to cause screen corruption with some applications, notably newsbeuter, finch, links, mc and hnb.




Not pretty.

This is simply fixed with 2 settings in putty. First, in the putty configuration tool go to "Terminal" and check the box for "Use background colour to erase screen". Then select "translation" found under the "Window" section and change the character set to "uft-8" using the drop down menu.

Here are the results:



Tuesday, April 13, 2010

Vim - Cut and Paste a Block of Text Between 2 Files

Vim is my editor of choice, but I would never consider myself an expert. So when I wanted to copy text from one text file to another in vim, I was challenged. Although I was frustrated for a brief moment, I remembered uncle google and he helped me with my conundrum. So here is how you cut and paste a section of text from one text file to another using vim.

First open your first text file in vim. Scroll down to the first line of the block of text you wish to copy and press "ma" (that is m followed by a, without the quotation marks). "m" marks the beginning of your block. The "a" makes the assignment of copying the text to buffer "a".

Now scroll to the end of the block of text you wish to copy and press "y'a" (again without the quotes). The "y" yanks the text block. The single quote in the middle, I guess designates the end of the block and "a" again identifies the buffer being used.

Next open the second text file by typing ":split filename.txt" (Remember no quotes). This will open the second text file in a split vim session window. Scroll to the line where you would like the text pasted and press "p" (You should know, don't include the quotes). This will paste the block of text on the line below the current cursor position. Save and your done.

Please leave comments with other examples of cutting and pasting in vim.
Enjoy.

Tuesday, March 16, 2010

id3 - Managing mp3 Tags

I listen to alot of podcast and very few of them actually use mp3 tags or they use tags that don't make sense to me. I have a sansa fuze media player which lists my podcast as "Season 3" or "Released as a Single" or simply "unknown". I mean how am I suppose to know what Season 3 is. Well, I've put a stop to the madness and use an application called id3 to change the mp3 tags, so I can have some sanity to my mp3 playlist.

One of my favorite podcast is for the TV show Lost, hosted by a father and son who discuss the show. The file name for the podcast is d66027dd-8873-2829-c731-97fcc5a62bb9.mp3. I know, but the name of the file really doesn't matter since the media player only really reads the tags associated with the file. To list the tags of the file:

id3 -l d66027dd-8873-2829-c731-97fcc5a62bb9.mp3


Which will give you the following output:

d66027dd-8873-2829-c731-97fcc5a62bb9.mp3:
Title : Lost Podcast (MP3): EP. 5.11 " Artist: Jeremiah Glatfelter
Album : Year: 2010, Genre: Unknown (255)
Comment:

My fuze displays this podcast as Jeremiah Glatfelter. Who the hell is Jeremiah? Maybe it's some inside joke or something, but the hosts of the show are Jay and Jack and that's what I would like displayed as the artist. So, to change the artist portion of the tag, I use the following:

id3 -a "Jay and Jack" d66027dd-8873-2829-c731-97fcc5a62bb9.mp3


Which outputs the following to show that the change has been made.

Title : Lost Podcast (MP3): EP. 5.11 " Artist: Jay and Jack
Album : Year: 2010, Genre: Unknown (255)
Comment:

Pretty straight forward. Here are the options to change the other aspects of the tags using the same syntax.

usage: id3 -[tTaAycg] `text' file1 [file2...]
id3 -d file1 [file2...]
id3 -l file1 [file2...]
id3 -L
id3 -v
-t Modifies a Title tag
-T Modifies a Track tag
-a Modifies an Artist tag
-A Modifies an Album tag
-y Modifies a Year tag
-c Modifies a Comment tag
-g Modifies a Genre tag
-l Lists an ID3 tag
-L Lists all genres
-R Uses an rfc822-style format for output
-d Deletes an ID3 tag
-h Displays this help info
-v Prints version info

Now you can tag to your hearts content.
enjoy.

Wednesday, March 10, 2010

My .bashrc File Part 5 - Pimping the Prompt


This is the final installment of my .bashrc series. PS1 is a variable that allows you to change your prompt environment. Here is my setting as found in my .bashrc file which I use to get the prompt above.

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

The numbers in the brackets represents colors. The \u option is username and \h is hostname which defines the first part of my command prompt. The second part of my prompt is indentified with /w which displays my current path which is shown above in blue.

Your possibilities are limitless when it comes to customizing your prompt and I don't have time here to list and explain all the options available, especially when the detail is readily available with a simple google search. Nevertheless, here are some links you might find useful to help pimp your prompt.

10 examples with syntax explanation.

This IBM article is a great resource as well.

I hope this series has been useful. Please share your pimped command prompt in the comments.

Monday, March 8, 2010

My .bashrc File Part 4 - Alias'

If you are unfamiliar with the alias command then you are missing out on an effective and efficient tool. Alias is a way to create a shortcut command in bash. You can take very long commands with several options or triggers and create your own shorthand equivalent of that long command. For Example, for me to get the weather for my local area using the weather-util application I would normally need to type:

weather -f --id=KSLC -c "Salt Lake City" -s UT

Well, that's way to long. I normally only want to know the weather in my local area, so I've created an alias for this long command.

alias weather='/usr/bin/weather -f --id=KSLC -c "Salt Lake City" -s UT'

This command essentially substitutes the longer command to display the weather for Salt Lake City with just the command "weather". I have several alias' in my .bashrc file to make my life easier.

# some ls aliases

alias ll='ls -l'

alias la='ls -A'

alias l='ls -CF'

#Information

alias weather='/usr/bin/weather -f --id=KSLC -c "Salt Lake City" -s UT'

alias gcalcli='gcalcli --cals all'

#For getting around

alias videos='cd /home/jared/Videos/ && ls'

alias pics='cd /home/jared/Pictures/ && ls'

alias music='cd /home/jared/Music/ && ls'

alias podcasts='cd /home/jared/Podcasts/ && ls'

alias dropbox='cd ~/Dropbox/ && ls'

alias documents='cd ~/Documents/ && ls'

alias notes='cd ~/Notes/ && ls'

alias manti='cd ~/Manti/jared/ && ls'

The first group of alias' are very common shortcuts for the "ls" command. The second group of alias' give me shortcuts for the weather and gcalcli applications which displays the weather and my google calendar information. Finally, the las group gives me shortcuts to commonly used directories. This saves me tons of time as I don't have to type out the complete path of a commonly used directory.

Please share some of your cool alias' that you have implemented.

Thursday, March 4, 2010

My .bashrc File Part 3 - Making Life Easier

A very common thing to do in the command line is to extract compressed files. Now as many of you probably know there are a dozen different compression methods out there. Let's say I have a .bz2, .7z, .gz and a .rar file and I don't want to think about which app to use and what option I need to extract my file. I just want my file uncompressed. Let's make life a little easier and insert the following into your .bashrc file.

#------Extraction of compressed files--------------
# from ARCH Wiki

extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "don't know how to extract '$1'..." ;;
esac
else
echo "'$1' is not a valid file!"
fi
}

Now when you need to uncompress a file, simply type "extract filename" and slam-bam-thank-you-ma'am. No thinking or looking up the correct syntax, all you are left with is an uncompressed file and isn't that all we really wanted?

What fun things are you hiding in your .bashrc file that makes life easier? Please share.

Wednesday, March 3, 2010

My .bashrc File Part 2 - Useful System Information

In the last segment I discussed displaying some useful personal information using a function script within my .bashrc file. Today I'll discuss displaying useful system information. I have two funtions which display system information, which is set up very similar to my previous script.



This first script displays my internal IP address and my WAN IP address by simply extracting that information from ifconfig whenever I type "myip" in the terminal. Here is the script.




function myip() # get IP adresses
{
MY_IP=$(/sbin/ifconfig eth0 awk "/inet/ { print $2 } " sed -e s/addr://) \ MY_ISP=$(/sbin/ifconfig
eth0 awk "/P-t-P/ { print $3 } " sed -e s/P-t-P://)
}




This displays:




External IP:
xxx.xxx.xxx.xxx
Internal IP:
192.168.0.97




This second function displays my machine statistics, file system space available, memory stats and IP information, when I type "ii" in the terminal. Here is the function:




function ii() # get current host related info
{
echo -e "\nHello ${RED}$USER"
echo -e "\nSystem information:$NC " ; uname -a
echo -e "\n${RED}Machine stats :$NC " ; uptime
echo -e "\n${RED}Storage stats :$NC " ; df -h grep -v varrun grep -v varlock grep -v udev grep -v\ devshm
echo -e "\n${RED}Memory stats :$NC " ; free -m
echo -e "\n${RED}Local IP Address :$NC" ; ifconfig grep
'inet addr:' grep -v '127.0.0.1' cut -d: -f2 awk '{ print $1}'
echo -e "\n${RED}ISP Address :$NC" ; wget
www.whatismyip.com/automation/n09230945.asp -O - -q
echo ""
}



You'll notice that in this script, my outside WAN IP is pulled from a website instead of from the ifconfig command. Here is the output:




Hello jared

System information:
Linux manti 2.6.24-24-server #1 SMP Fri Sep 18 17:24:10 UTC
2009 i686 GNU/Linux


Machine stats :
10:02:17 up 81 days, 15:14, 10 users, load average: 0.15, 0.38, 0.37

Storage stats :
Filesystem
Size Used Avail Use% Mounted on

/dev/sda1 17G 3.0G 13G 19% /
/dev/sda2 276G 246G 16G 94% /home
/dev/sdb1 187G 146G 32G 82% /media/backup

Memory stats :
total used free shared buffers cached
Mem: 502 492 10 0 37 65
-/+ buffers/cache: 389 113
Swap: 1874 30 1844

Local IP Address :
192.168.0.97
ISP Address :

xxx.xxx.xxx.xxx


I apologize that not everything is lined up correctly, it's due to the layout in blogger. The output lines up fairly cleanly in the terminal.

Enjoy!

Monday, March 1, 2010

My .bashrc File Part 1 - Useful Information

I thought it would fun to have a short series regarding my .bashrc file. Feel free to share any cool aspects or insights from your .bashrc file during this series. A short disclaimer for this series, regarding most of what I will be sharing with you is NOT original content. I've copied most aspects of my .bashrc from others who have been so kind to share their cool ideas. Now, lets begin.

I want to focus the first apart of this series on having bash display useful information in an easily accessible and concise way. For example, the first thing I do each morning is run my "update" script which displays the time, my schedule for the day and the weather, which looks something like this:

Hello jared, How are you today?

Current Date and Time:

Fri Feb 26 09:00:40 MST 2010

Your Schedule:
Mon Feb 22 12:00am Zone 4
Fri Feb 26 12:00am Safety Kids Fair

6:30am Scriptures
11:00am Preschool time
Sat Feb 27 9:30am Food Co-op Pick up

Current Weather Conditons:

Current conditions at UT (KSLC)
Last updated Feb 26, 2010 - 10:53 AM EST / 2010.02.26 1553 UTC
Wind: from the SSE (160 degrees) at 13 MPH (11 KT)
Sky conditions: mostly cloudy
Temperature: 35.1 F (1.7 C)
Relative Humidity: 69%
City Forecast for Salt Lake City, UT


Here is the script I use in my .bashrc file.

function update() # Current date, time, weather and calendar
(
echo -e "\nHello $USER, How are you today?"
echo -e "\nCurrent Date and Time: $NC " ; date
echo -e "\nYour Schedule: $NC " ; gcalcli agenda head
echo -e "\nCurrent Weather Conditons: $NC " ; weather head -n 7
echo ""
)

Let me run through this function. As you can see it's all just echo commands spewing out the information I desire. I begin by having bash say "Hello" to me. Just because it's a shell doesn't mean it can't be polite. Next it displays the current date and time which is followed by my schedule for the day. My schedule is produced by a cool little app called gcalcli which was a Google summer of code project that displays your google calendar on the command line. I blogged about this app previously here. I then finish things up with the weather using the weather-utils application. I have the weather command set up as an alias (which I'll cover in another segment) to display my local weather.

As mentioned previously, this is the first command I type into the terminal when I first wake up, which gives me a quick and concise outlook for the day.

Well, I hope this was interesting to some of you. My next installment will cover displaying useful system information. So until then... enjoy!

Monday, February 22, 2010

Catching up with Arch Linux

Let's begin with a little update. I've been off-line for a few months now, mostly due to a new job and just feeling like I needed a break. Recently though, I've been having the urges to blog again, mostly due to Quvmoh putting the audio of my presentation "Life without a GUI" from UTOSC on HPR. (thanks Quvmoh) This also reminded me that I need to put my slides up from the presentation which you can find here. Use the tpp application to view them as slides or any text editor will work as well. You can also download my handout of the presentation here. The handout will give you useful links for file conversion and the syntax for playing video in the framebuffer.

The last time I blogged I was praising Slackware, but since then I've moved on to Arch. Don't get me wrong Slackware is awesome, but there was one unforgiving issue that caused me to dump Slack for Arch. It was the lack of supported software for Slackware. I just couldn't find everything I wanted on the main repo or on slackbuild.org or anywhere else. One example of this was tuxpaint for my son. I just could not get it installed on my 64-bit system. After hours of frustration without any progress I was done. This is tuxpaint for heaven's sake, it shouldn't be this hard, especially when I could easily just "apt-get install tuxpaint" on Debian/Ubuntu or "yum install tuxpaint" on Fedora or "pacman -S tuxpaint" on Arch.

And speaking of pacman... WOW! I'm in love. It really does put apt to shame. It is so fast. I literally blink and applications are installed. More praises for Arch, include the rolling release methodology. I always have the latest and greatest stuff and everything is stable. I just can't say enough about it. I recommend everyone to give it a try.

Finally, I've been throwing around the idea of doing a Linux command line podcast. I figure it's a niche topic that's not exclusively covered in any other linux podcast. I would cover alot of what my UTOSC presentation was all about, "How to live life and get everything done in the command line." Topics I might cover could include: How to deal with various office document formats, How to blog from the command line, How to email and view attachments from the command line, How to do photo editing from the CLI, discuss how to use the various apps listed on my CLI apps list or maybe interview the developers of these apps, and so on. For the 2 people out there that read my blog let me know what you think. If anyone is interested and would like to co-host that would be great. Now all this being said, I really don't know anything about podcasting so if anyone could give me some tips or advice or just point me in the right direction that would be greatly appreciated.

Friday, July 17, 2009

Redirected Domain

I love DynDNS. It's a great service. Using this service, I've registered cli.homelinux.net and redirected jaredandcorlee.com to that domain.

The new CLI domain better fits the subject matter on the site. If you haven't checked out the site, please give it a look over. Understand that it still needs work, but definitely stop by the CLI applications list which is the core focus of the site. Also, please send your CLI suggestions and site recommendations.

Tuesday, June 16, 2009

Command Line Webite

Shortly after I got married my brother purchased the jaredandcoralee.com domain as a birthday present. We used this site as a family website to post pictures and other family related stuff until my wife discovered blogger. The family site got neglected as blogger took over the role and purpose of the old site. So, I still have the domain and decided to turn it into a Linux command line site.

It's a complimentary site to this blog, focusing on getting things done on the desktop linux command line. It still needs alot of work and I will fix it up and add to it as time allows. Please feel free to offer suggestions or contribute as you so desire. Hopefully, it will of use to someone out there.

Here's the link. http://jaredandcoralee.com/

Thanks.

Thursday, February 26, 2009

Watch Battlestar Galactica on Your Phone.

I have a crappy Nokia flip phone. There is nothing special about it. It does have a camera and can take really poor quality video if you happen to be standing in reasonable light. It does have have a media player to watch these videos which are formatted in .3gp, which I guess is very common in these small portable devices. I also have a 1 Gb micro SD card for storage on my phone. So far nothing too outlandish about this phone or it's features. These features are found on the most basic "free" phone given to you by carriers when you sign away your 1st born with one of their contracts. This is definately not a iPhone or some other overpriced "smartphone".

Anyway I wanted to see if I could watch Battlestar Galactica on my phone while on the bus to work each morning and found that it's not that difficult with Free open source software. My Battlestar Galactica episodes in .avi format, so I just needed a way to convert my .avi file to .3pg. Then put that newly created .3pg file on my microSD card and fire up my media player on my phone and I should be good to go. Here is how I did it.

Install the following: ffmpeg, amrnb, amrwb and sox. In debian based distros it's pretty straight forward with apt-get and each of these applications are in the Ubuntu repos. Then issue the follow command:

ffmpeg -i inputfile.avi -s qcif -vcodec h263 -acodec aac -ac 1 -ar 44100 -r 25 -ab 192 -y outputfile.3gp
Here is a brief breakdown of the ffmpeg command. You can find more detail on the ffmpeg man page.

-i input file
-s video size (qcif=176x144, see man page)
-vcodec video codec (needed for the conversion)
-acodec audio codec
-ac # if audio channels
-ar Audio frequency
-r Frame rate
-ab audio bitrate
-y output file

You may have to fiddle with the frame rate a bit to what works best for you on your device. I've converted one file and played it on 2 different devices and the audio and video sync was off on one and not the other, which tells me that something funky is going on with different media players. I would recommend that you keep the audio quality (freq and bitrate) high because the speakers on most of these low quality device are pretty crappy. You will want to have goo sound quality if you expect to hear anything.

A one hr long episode of Battlestar Galatica in .avi is about 350 mb, once converted to .3pg with the above configuration rates is about 80 mb.

If you have mpeg files you would like to convert, use the following:

ffmpeg -i inputfile.mpg -s qcif -vcodec h263 -acodec aac -ac 1 -ar 8000 -r 25 -ab 32 -y outputfile.3gp
If you're try to get videos off your phone to watch on your computer, here convert your files the other way.

ffmpeg -i clip.3gp -f avi -vcodec xvid -acodec mp3 -ar 22050 file.avi
Enjoy!

Friday, November 28, 2008

Your Little Black Book - Using a Text File and grep

This tutorial incorporates grep, nano and awk to search a text file of contacts to create a CLI PIM manager or address book and demonstrates well the power of the CLI. You do not need to have any knowledge of these commands to
follow the tutorial, but an understanding of such commands will aid in understanding the concepts being applied.

This address book and contact manager will have the following characteristics:

  1. be able to search and view records whenever you need them, from the command line and a text editor.
  2. perfectly accessible over a slow text-only network line
  3. be able to cut and paste addresses and contact information from the Web, email, and any other applications
  4. have no concept of "required fields" -- each record can contain as much, or as little, information as you need to have.
  5. can be taken with you and used on any Linux or Unix machine

Creating the Addresses file

The first step is to make a new file (call it something like "addresses"), you can do so by typing:

nano addresses
Now, you can begin adding records to it.

Records have to be delimited somehow; I would suggest putting ### on a line by itself between each set of contact information. Format the records themselves however you like, with name and address and whatever information you have. I used to keep a completely free-form contacts file, so that each record contained completely unformatted data in whatever way that I happened to get it, but this practice quickly shows its limitations -- I've found
that it helps immensely to label certain fields, such as telephone number and email address. I use this format:

Name
Address
Phone: phone number
Fax: fax number
Email: email address
Comments: additional information
As an example, a few records might look like this:

---------------------------------------------------

Acme Industries, Inc.
4211 E Broadway
New York, NY 10026
Phone: (212) 555-1032
Fax: (212) 555-1038
Email: acme@example.net

###

capri pizza
Phone: 555-8250

###

jane smith
Phone: 555-3104
Email: jsmith@example.nyu.edu
Comments: friend of susan's

------------------------------------------------
Searching, browsing, and exporting records

Create the following script to make searching for a contact easy.

#!/bin/sh
awk 'BEGIN { RS = "###" } /'$*'/' ~/addresses
Name the script "contact" and make it executable (chmod +x contact). Make sure that your Address file and your contact script are in the same directory or place the script somewhere within your path.

At the command line simply type:
contact jane

or

./contact jane

This should bring up Jane Smith's contact information as found in the text file. You can search using any of the information in the text file. Here are some examples:

contact nyu.edu
will give you all contacts with a 'nyu.edu' email address.

contact 90028
will give you all the contacts living in the that zip code. You search options are limitless.


More Advanced Searching using grep and awk

fgrep outputs single lines of the file that match a string you give, and is good for when you just want to see if you have such-and-such a record in your file. Use the -i option to do a case-insensitive search -- for instance, here's how to see if you have contact information for Acme
Industries:

fgrep -i 'acme industries' addresses
Should display:

Acme Industries, Inc.
The output gave the name -- but you want the phone number too. Output the search with a few lines after the match with the -A option:

fgrep -i -A5 'acme industries' addresses
Which will display the next 5 lines following the name 'acme industries', like this:

Acme Industries, Inc.
4211 E Broadway
New York, NY 10026
Phone: (212) 555-1032
Fax: (212) 555-1038
Email: acme@example.net
And here's where using labels really pays off. When you need, say, all the email addresses that have "nyu.edu" in them, you can find them with a plain grep command:

$ grep '^Email:' addresses | fgrep 'nyu.edu'
Then you can simply copy and paste the listed emails into your email client.

Harvesting the actual addresses themselves is also a trivial matter:

$ grep '^Email:' addresses|egrep -o '[^ ]+$'
You can use awk to output entire records containing a particular match. The simplest way is to change the awk record separator, RS, to ### and then enclose the pattern to match in slashes. For example, here's how to export all records containing the string "acme" somewhere in the record:

awk 'BEGIN { RS = "###" } /acme/' addresses
and you will get:

Acme Industries, Inc.
4211 E Broadway
New York, NY 10026
Phone: (212) 555-1032
Fax: (212) 555-1038
Email: acme@example.net
The contact script we first used in this tutorial is based off of this awk command.

Because the file has labels, you can limit your search to them. For example, you can search for all email addresses that have "smith" in them, and output the entire records:

awk 'BEGIN { RS = "###"; FS = "Email: " } ($2 ~ "smith") { print $0 }' addresses
You can use the same awk pattern to do any number of things. For instance, in conjunction with the grep examples above you can output all the email addresses in records that have "friend" in the comment field:

$ awk 'BEGIN { RS = "###"; FS = "Comments: " } ($2 ~ "friend") { print }' addresses | grep '^Email:' | egrep -o '[^ ]+$'
Adding and importing records

Adding records to your contacts file is easy. The file doesn't need to be sorted, so append new records by either editing the file in nano or using redirection on the command line:

cat >> addresses
then type in your new contact, like this:

###
new name
Cell: 801-123-4567

This will add the 'new name' to the bottom of your addresses file.

Rarely do I actually type out any new contact information myself -- that only happens when I'm transcribing something from paper, or when I'm getting a number from someone on the phone. Nine times out of 10 I'm just cutting and pasting the text from the Web or email into an editor window that has
the contacts file open. It's painless and fast -- there are no forms to have to fill out for each part of the record. But you have to keep two things in mind: separate the records with hash marks, and insert labels for numbers, email, and comment fields, if you want to use them.

If you already have a set of address records formatted some other way, awk can import it so that it's in the right format.

Let's say you have a file named address.txt where all the records are kept one to a line in this common format:

lastname,firstname,address,city,state,zip,phone,email

Here's an awk one-liner to take that input and spit it out into the bottom of the addresses file, in just the right format:

$ awk 'BEGIN { FS = "," } { print "\n###\n\n" $2, $1, "\n" $3 "\n" $4 ", " $5, $6, "\nPhone: " $7, "\nEmail: " $8 }' address.txt >> addresses
ENJOY!

Disclaimer:
This tutorial is a re-publication from an article from linux.com a few years back with some slight modifications from me. I'm unable to find the original article to link. If anyone knows who originally published this please let me know and I'll make the necessary reference.

Monday, November 24, 2008

Is that a Fish in Your CLI? The asciiquarium Screensaver.

We've all seen the aquarium screensavers with fish swimming around our monitor. Well that calming soothing fish love isn't just for the CLI haters. Command line activists can also go fishing via the terminal with asciiquarium.

asciiquarium is not in the Ubuntu repositories but don't let that scare you. asciiquarium is a perl script which gives us easy access to this fun little program. Before we can see our fishy friends there are some dependencies we need, perl (of course), curses and the Term::Animation module. perl and curses is found in most of Linux distros by default, but I had to install the Term::Animation module from source which was pretty easy on Ubuntu. You can get Term::Animation from freshmeat.net. Just download Term::Animation, uncompress, enter the newly created directory and proceed with the following steps in the terminal,

1. perl Makefile.PL
2. make
3. make test
4. make install


Once installed, download asciiquarium from here, uncompress, enter the newly created directory and type the following.

./asciiquarium



Once running, pressing "r" will redraw the image, "p" will pause the animation and "q" will quit the program.

Watching all these fish are making me hungry. I think I'm in the mood of a good fish taco.

Happy fishing.

Friday, November 7, 2008

How's the Weather up there? CLI weather app.

weather-util gives you local weather readings on the command line. If you are running Ubuntu you can easily install this handy little application by typing the following in the command line.

$apt-get install weather-util
To retrieve local weather information you will need to know your local weather id which can be found at the National Weather Service. Your id is a 4 digit letter code which identifies your city or area. I live in Salt Lake City, Utah and my id is KSLC.

Once you have your id the syntax is fairly straight forward.

$weather -id=KSLC
Which outputs the following:

Current conditions at UT (KSLC)
Last updated Nov 07, 2008 - 09:53 AM EST / 2008.11.07 1453 UTC
Wind: from the SE (140 degrees) at 8 MPH (7 KT)
Sky conditions: mostly cloudy
Temperature: 39.9 F (4.4 C)
Relative Humidity: 62%

You can get a forecast using the -f option.

Current conditions at UT (KSLC)
Last updated Nov 20, 2008 - 08:53 AM EST / 2008.11.20 1353 UTC
Wind: Calm
Sky conditions: partly cloudy
Temperature: 32.0 F (0.0 C)
Relative Humidity: 85%
Issued Thursday morning - Nov 20, 2008
Thursday... Sunny, high 55, 0% chance of precipitation.
Thursday night... Low 30, 10% chance of precipitation.
Friday... Sunny, high 43, 0% chance of precipitation.
Friday night... Low 21.
Saturday... High 45.


Now you have no excuse to be caught out in the cold unprepared. If you can muster up some creative juices I'm sure you could easily get the output to display in conky.

Friday, October 24, 2008

gcalcli - Google Calendar on the Command Line

gcalcli gives you access to your Google Calendar on the command line. You can retrieve your calendar information for multiple calendars and in various formats. gcalcli can be found in the repositories for Ubuntu Hardy and Ibex.

If your Distro does not have gcalcli in it's repositories, instructions can be found here. gcalcli is written in python and just has a few dependencies for an easy install.

Once installed you may need to create a .gcalclirc file in your home directory. The file should be configured like this:

[gcalcli]
<config-item>: <value>
<config-item>: <value>
...

Mine looks like this:

[gcalcli]
user: username@gmail.com
pw: password
cals: all

Obviously, use your own Google Calendar username and password in the file. I have several calendars that follow, like a US Holiday calendar, a family birthday calendar and my Wife's calendar. I wanted to have access to all the calendars so I indicated that as an option in the config file. There are several other options that can be included within this configuration file specifically having different colors for each calendar.

On my laptop running CrunchBang! Linux, gcalcli was not correctly reading
the .gcalclirc file. So, I created the following alias in my .bashrc file:

alias gcalcli = "/usr/bin/gcalcli --user=username@gmail.com --pw=password"

This seemed like a reasonable work around for now.

To view my calendar I simply type:

$ gcalcli agenda


Notice my calendar in blue and my wife's calendar in magenta.
Using the agenda option without parameters will list one week of calendar information. You can include a date range to customize the output.

$ gcalcli agenda 11/15 11/31

This will give you all calendar items between 11/15 and 11/31 of the current year.

To view your calendar in a matrix with borders, type the following:

$ gcalcli calw

The calw option without parameters will display the current week's calendar items. You can add parameters to increase your ranges view.

$ gcalcli calw 3


This will display the current week and the following 2 weeks.

You can post to your calendar as well using the quick option in the following syntax.

$ gcalcli quick "10/31 7 pm Halloween Party"


This will create a calendar for a Halloween Party on 10/31 at 7 pm.
Please see the gcalcli site for more things you can do with this neat little app, including adding calendar items to gnu screen and receiving notices. For all you GUI lovers you can even use gcalcli to display your calendar items in conky.

Now you can do all your scheduling and calendaring on the CLI.

Wednesday, October 22, 2008

Everything Can be Done in the CLI (Mostly)

I love the command line and truly believe that it is an ideal interface for the Desktop. It's speed is unparalleled. It's simplicity and flexibility is far superior to anything that can be done with xorg and any GUI. Mind, I'm not a completely idealistic or ignorant to the advantages of a GUI. I'm a KDE and Openbox fan, but I'm constantly drawn to the sheer power and flexibility of the command line that I feel can never truly be reach by a GUI.

I am also drawn to Desktop applications because it is what I know and use everyday and it is what I find interesting. Most people use a computer as a Desktop. Server administrating my may be interesting to some, but I find it very boring and frustrating. Plus, most sys admin's tasks are done on the CLI anyway.

I passionately feel that nearly all tasks that are done in the Desktop can be done from the CLI. I understand that there might need to be some "work-arounds" or extra steps taken on the CLI to accomplish a similar task in the GUI, yet I think it will be a fun challenge.

This being said, I have begun a list of Desktop tasks and the command line applications or options available to complete those tasks. You can find this list here. This is just a list I've thrown together, which I hope to develop as a much bigger community resource. It is a work in progress which I hope to expand and improve. My vision is to have each application link to a resource of some kind. It may link to a tutorial which explains how to use the application or a link to a script that automates a long or repetitive process. Essentially, I want it to be a resource for users to draw upon to be able to complete any Desktop task in command line.

Please send me recommendations as to how to improve this resource. Help me to fill in the blanks. You'll notice a lot of blanks in the Development section. That's because I'm not a developer. Help me with additional solutions to tasks. Please offer suggestions as to how to improve the layout or organization of the list. I hope to have this hosted on my own website sometime, but for simplicity sake I have it on Google Docs. Please make any other suggestions you see fit.

Ways to make comment:
1. make a comment to this post.
2. email: jared (dot) bernard ((@)) gmail (dot) com
3. twitter: https://twitter.com/moriancumer
4. identi.ca: http://identi.ca/moriancumer

Friday, December 14, 2007

What's in a Logo?

I need a logo for SimpleCLI Desktop.

The logo needs to summarize all the ideals and concepts of SimpleCLI Desktop into one concise marketable image.

I was thinking of using this image:






and integrating some text, similar to this:

SimpleCLI:
~$ >
Desktop

Let me know what you think?

Now all I need to do is put on some finishing touches and create the .iso image. The logo is one of those finishing touches. I'll post the logo here as soon as I'm done with it.

Thursday, December 13, 2007

Yet Another Linux Distro?

Yep! :)
Why you ask? Well let me tell you...

I love the command line because of it's flexibility, it's quickness and it's productivity. It's liberating. You can do nearly anything in the CLI that can be done in the GUI, yet many people are intimated with the command line and therefore shy away from it. Hence, my idea to produce a user-noob-friendly CLI Linux Desktop Distro. I want to introduce people to the command line in a warm way. I want people who are new to the command line to be able to jump into a CLI environment and be able to immediately do what they do everyday on a computer with little anxiety and a minimal learning curve.

I also want to educate people that you can be productive and do things on your computer in the Command Line Interface. Things that most people would think was impossible in the CLI. You can view, edit, organize and manipulate your pictures. You can watch and edit video. You can burn CD's and listen to music, browse the internet and watch youtube videos, and it's not that hard. You don't have to memorize thousands of awkward long commands, because I'll be holding your hand. Then when you feel comfortable to venture out on your own, their are resources and examples built-in which will teach you, at your own pace, how to customize or adapt your system to your specialized needs.

Now, I'll admit that not everything on the command line is as easy as the GUI. Word Processing is one good example of this. I recommend using Latex to work around this issue since there is no known true CLI word processors. I've created some Latex templates to make things easier, but still... there is a slight learning curve. Yet, I feel with just one or two minutes of simple instruction and using a template, anyone can create a beautiful looking and professional document in no time.

Am I reinventing the wheel? No. There is no CLI only Desktop distro. Most distros with a CLI environment are for servers or specialized flavors like tomsrtbt. I propose that if a user wants to feel comfortable on the command line he or she should do so by doing normal everyday things, not by learning to configuring sendmail or editing config files.

Now to answer the questions addressed. Why must I create a new Linux distro to achieve the goals I've just outlined? Why don't I just make a Ubuntu Package that includes my tutorials and application menu? The answer is because the GUI is very tempting. I want to isolate the user in the CLI environment as much as possible. If a user was to use my tutorials or application in a terminal emulator like gnome-terminal or Konsole and they encountered a small bump in trying to perform a function, it's too easy to say, " Screw it! I'm just going to open up OOo Writer to type my paper". If the user is engulfed in the environment, then it's a little tougher to do that. Granted, if they are running the LiveCD all they need to do is reboot, also since SimpleCLI Desktop will be based on Ubuntu-server they can easily just "apt-get install ubuntu-desktop" to get X up and running. Still, it takes just that much more effort to escape the CLI environment if its the only environment running. In addition, when the user finally does get over that little bump, they are a better person for it and they've learned and are less likely to forget what they've learned.

It's just like trying to learn a foreign language. The best way is to be immersed in the environment. Surround yourself with others that speak the language you are trying to learn and try to communicate as you normally would. Use resources to get by and eventually you'll feel more comfortable with the language. This is the premise of SimpleCLI Desktop.

Wednesday, December 12, 2007

SimpleCLI Desktop

SimpleCLI Desktop is my new Linux distribution I hope to have available by the end of the year. I believe about as many people as read this blog (zero) will actually be interested in what I'm trying to develop. Nevertheless, I think this is a niche product that has yet to be made available to the community, and who knows maybe one other person out there will actually find this cool also.

I'd like to explain what I'm trying to create with SimpleCLI Desktop. So, here is an outline of my objectives:

1. An easy to use (newbie friendly) Command Line Interface (CLI) only Linux Distribution. That's right ,NO GUI. It will have a menu driven interface custom developed by me :) which will easily initiate applications and processes. Think of it as the CLI version of the start menu or application menu. Basic instructions will be displayed at login.

2. Help create a friendly environment for anyone wanting to learn the command line. There will be built in tutorials that will be constantly updated and expanded. Tutorials can be accessed through the application menu.

3. Designed for desktop use. Most of what people do on a computer is desktop stuff like: Surf the Internet, email, word processing, play games, listen to music, watch videos, view pictures, blog, instant message, etc. All of this can be done in a CLI environment, using very little system resources and is easy to do. I want to show the power of the CLI and it's simplicity.

4. Be used as a LiveCD distro. I want people to be able to use this anywhere.

Hopefully, the name now makes sense.
The distro will be based on Ubuntu-server and created using the Remastersys script.

In my next Blog I'll explain why I'm creating an entire distro and not just a Ubuntu package with my application script and tutorials.