sontek ( John M. Anderson )

January 25, 2008

Progress bar with cp

Filed under: Bash, Linux — Tags: , — sontek @ 9:42 am

Today I found a very informative post on how to get a progress bar with the cp command in Linux.

You can find that blog post here. But I’ll repost the information here in case his blog ever disappears.

With the following bash script:

#!/bin/sh
cp_p()
{
   set -e
   strace -q -ewrite cp -- "${1}" "${2}" 2>&1 \
      | awk '{
	    count += $NF
            if (count % 10 == 0) {
               percent = count / total_size * 100
               printf "%3d%% [", percent
               for (i=0;i<=percent;i++)
                  printf "="
               printf ">"
               for (i=percent;i<100;i++)
                  printf " "
               printf "]\r"
            }
         }
         END { print "" }' total_size=$(stat -c '%s' "${1}") count=0
}



You will get a progress bar like this:


% cp_p /mnt/raid/pub/iso/debian/debian-2.2r4potato-i386-netinst.iso /dev/null
76% [===========================================> ]

January 2, 2008

Pimp my irssi

Filed under: Linux — Tags: , — sontek @ 12:52 am

To start the new year, I was wondering what everyone’s favorite theme, scripts, and hacks for irssi are. I currently use the default irssi theme with the following scripts:

  • nicklist.pl - Allows me to see the user list in each channel, giving it the feel of the majority GUI IRC clients.
  • screen_away.pl - When I detach from my screen it will then set me to away and save any highlighted messages into the status window so I can easily respond to my people who were talking to me.
  • trackbar.pl - Sets a line at the last line that was viewable before I switched channels/windows, that way I can easily find the last place I read and continue from there.
  • splitlong.pl - Splits long messages

outside of the custom scripts I use, I also have:

scrollback_lines 100000
autolog = "yes"
autolog_path = "~/.irssi/irclogs/$tag/$0-%m%y.log"

Powered by WordPress