Tuesday, May 4, 2010

Install Vim-outliner on K/Ubuntu

I spoke of vim-outliner a few years ago and was recently reminded of it again while listening to the mintcast podcast regarding orgmode for emacs.

Orgmode seems to be fairly feature rich, but I never liked the whole key combination thing with emacs. To this day, I can't figured out how to close an emacs session. Vim just seems easier. It's a preference.

Vim-outliner doesn't seems to have all the features of orgmode on the great emacs OS, but it is good at what it does...outline. It seems to follow the Unix philosophy of doing one thing and doing it well, instead of the emacs philosophy of cram as much as possible into an app. So I attempted to install it on my Kubuntu 9.10 machine and it's not as simple as an aptitude install. So, here is how to get vim-outliner installed and set up on a current version of K/Ubuntu.

$ aptitude install vim-vimoutliner

Make sure you have vim-addon-manager installed. If not install it. Then,

$ sudo vim-addons -w install vimoutliner

Finally, make sure you have the following in your ~/.vimrc file, if you don't already,

filetype plugin indent on

To start vim-outliner, simply open vim with any file with the extention .otl, such as:

vim file.otl

and you're good to go. Please visit my prior post on vim-outliner for a quick tutorial or use vim's help to access the documentation by typing ":help vo" in an open vim session.

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.

Friday, April 2, 2010

Newsbeuter and Google Reader



If you go to the newsbeuter website you'll be told that it's the mutt of rss feed readers. It is text based and highly configurable. Newsbeuter is fairly easy to set up and configure. Just install newsbeuter using your distros package manager. It should be available on most distributions Ubuntu, Fedora, Opensuse, Arch, Slackware, Debian, etc.

Now that it's installed, just type newsbeuter in the terminal to start it. There's probably not much to see as we haven't added any RSS feeds yet, but I usually start an application before configuring it because usually there are configuration files that are created when an app first starts up. Press "q" to quit.

To add feeds open the ~/.newsbeuter/urls file and simply add your feed urls to that file. Save and close and you're good as gold. You can edit the ~/.newsbeuter/config file to customize your keybindings and other settings. See the man page for configuration options.

I recently learned that you can use newsbeuter to view your Google Reader feeds. To do this make sure you have the latest version of newsbeuter and simply add the following to your ~/.newsbeuter/config file.

urls-source "googlereader"
googlereader-login "your-googlereader-account"
googlereader-password "your-password"

Save and start newsbeuter. You now have your Google Reader Feeds.
Please see the newsbeuter documentation site for more configuration options.
Enjoy.

Tuesday, March 23, 2010

HTML Editors for Beginners

In about two weeks, I'll begin teaching an HTML class and I'll need a good HTML editor with syntax highlighting. I need something cross platform as I know that most students will be using Windows and at least one will be using a MAC. I, of course, will be using Linux. I prefer using vim.

Vim is great as I can run it at the command line, in a GUI (gvim) and on any OS you can think of. Within vim you can activate html syntax highlighting by simply typing:

:set syntax=html

That will add html syntax highlighting for only that session of vim. You will need to add "syntax on" in your .vimrc file for highlighting to be permanent.

Now as much as I love vim, I'm not going to have my students use it. This is an HTML class for the absolute beginner and introducing vim to the class is a hurdle I don't want to jump over. So, I'm leaning towards having my students use bluefish. Bluefish has several cool features including running on all three major platforms.

Any other suggestions for an HTML editor for beginners? What features do you like? What are your thoughts regarding bluefish?

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.

Friday, March 5, 2010

You Know You're a Geek If.....

.......YOU GET EXCITED ABOUT RAM!!!!!!!!!

I haven't been able to sleep at night for the last 3 days in anticipation of the RAM upgrade I ordered from newegg for my HP 1000 mini. The mini originally came with 1 GB RAM and I'm maxing it's compacity with 2 GB. The climatic release of tension came when my RAM (finally!) arrived and I could pop in the SODIMM into it's slot and gasp in awe at the increased performance from this baby.

Whew! What a rush.

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!

Thursday, February 25, 2010

KDE 4.4 Features

I have been really impressed with KDE 4.x, so when 4.4 recently came out, I was excited to try it out. You can get KDE 4.4 for Kubuntu through PPA and Arch already has it available in their main repo. Here are some of the cool new features that will make your Gnome loving friends jealous.

New Plasmoids and added features.
  • Improved folder view plasmoid, hover mouse a folder to view it's contents
  • improved device notifier, gives options for handling devices
  • webslice to view a portion of a website
  • Spell checker
Window Management
  • ctrl+F9 to view all open windows (similar to expose in OSX)
  • ctrl+F7 to view all grouped windows
  • ctrl+ F8 to view all desktops - my absolute favorite

  • Tabbed Windows (just like fluxbox)
  • Improved Krunner with plugins - shows devices, firefox bookmarks, wikipedia (mediawiki plugin), calculator, etc (Leave Gnome-Do in the dust)
  • Timeline:/ protocol to sort by time
  • Kmix has multimedia keyboard support
  • Can flag devices for auto mounting
AND a new netbook desktop. I've never been keen on the moblin/ubuntu netbook remix look. Joulicloud was better, but nothing great. KDE netbook desktop is not perfect, but is better then any of the other choices that are currently available.


I installed it on my netbook running Arch and it's not bad. I definitely like the icons on the desktop and the search field is really handy.

Also some cool new apps.
  • rekonq - my favorite new app, konquorer with webkit or Konquorer done right
  • palapeli - an actual jigaw puzzle game
Anyway, go check KDE 4.4 out and read about its new features here.

Wednesday, February 24, 2010

pwsafe - Password Keeper

I don't know about you but, I have a butt load of usernames and passwords. I try not to use the same username and password for facebook, twitter, my bank, work, etc for what I hope is obvious security reasons. I desperately needed something to manage my passwords, which lead me to find pwsafe. From the man page, "pwsafe [is a] commandline password database utility compatible with Counterpane's Passwordsafe." It has been really handy.

pwsafe is in the Debian/Ubuntu repositories and I assume should be in most of the major Linux distributions. If you can't find it for your distro, you can get it here.

Once installed, you will need to create a new database.
$ pwsafe --createdb

You be asked to create a password for this database, make sure it is unique, secure and don't forget it.

Once that is done you're ready to add an entry.

$ pwsafe -a name


This will initiate the following:

Enter passphrase for /home/jared/.pwsafe.dat:
group []: Web
username: xxxxxxxxx
password [return for random]:
password again:
notes: access to jaredandcoralee.com ftp and panel


This is pretty straight forward. You are asked for your passphrase (the one
created when you first set up your database) and then a group name. This is a
nice feature to catagorize your passwords. I have a group for Finance, Websites,
Work, etc. You can then search or list information just for those groups. Next you will enter a username, password (twice) and notes. The notes is nice for security questions you may be asked on bank sites for authentication where you can never remember the answer.

To view a list of entries with in a group.

$ pwsafe -l groupname


You will be prompted for your passphrase. The groupname is optional, but helps cut down on the output. This will just print out group, name and your notes. No passwords will be displayed.

To view your passwords,

$ pwsafe -upE name


Again you will be prompted for your passphrase and your username and password will be displayed. There's a lot more you can do with pwsafe. See the man page for more info.

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.