which cool programmes and/or bits of code do you use that others might find useful?

Discussion in 'all things UNIX' started by iceni60, Jan 28, 2010.

Thread Status:
Not open for further replies.
  1. iceni60

    iceni60 ( ^o^)

    Joined:
    Jun 29, 2004
    Posts:
    5,116
    i was going to reply to the poll about compression software, but thought it would be better in the unix forum ;)

    here are some options for unpacking archives (i just copied and pasted what i was going to write in my original reply, it should mostly make sense) -

    i always used tugzip with windows and sometimes winrar.

    on linux i've added the unpacking commands separately to the right-click option in my filemanager - thunar. i added an extract alias for my terminal with this function -
    Code:
    iceni60 ~ $ type extract
    extract is a function
    extract () 
    { 
        if [ -f $1 ]; then
            case $1 in 
                *.tar.bz2)
                    tar xjf $1
                ;;
                *.tar.gz)
                    tar xzf $1
                ;;
                *.bz2)
                    bunzip2 $1
                ;;
                *.rar)
                    rar x $1
                ;;
                *.gz)
                    gunzip $1
                ;;
                *.tar)
                    tar xf $1
                ;;
                *.tbz2)
                    tar xjf $1
                ;;
                *.tgz)
                    tar xzf $1
                ;;
                *.zip)
                    unzip $1
                ;;
                *.Z)
                    uncompress $1
                ;;
                *.7z)
                    7z x $1
                ;;
                *)
                    echo "'$1' cannot be extracted via extract()"
                ;;
            esac;
        else
            echo "'$1' is not a valid file";
        fi
    }
    
    i got this one too :cool:
    Code:
    iceni60 ~ $ type unpack
    unpack is aliased to `/home/iceni60/scripts/unpack2dir.sh'
    that leads to this -
    Code:
    iceni60 ~ $ cat /home/iceni60/scripts/unpack2dir.sh
    #! /bin/sh
    # #############################################################################
    
           NAME_="unpack2dir"
           HTML_="uncompress unpack script"
        PURPOSE_="unpack zip, tar, tgz, tar.gz, tar.bz2, tar.z to a dir of the same name as archive prefix"
       SYNOPSIS_="$NAME_ [-vhlr] <file> [file...]"
       REQUIRES_="standard GNU commands"
        VERSION_="1.2"
           DATE_="1999-09-20; last update: 2006-02-03"
         AUTHOR_="Dawid Michalczyk <dm@eonworks.com>"
            URL_="www.comp.eonworks.com"
       CATEGORY_="compress"
       PLATFORM_="Linux"
          SHELL_="bash"
     DISTRIBUTE_="yes"
    
    # #############################################################################
    # This program is distributed under the terms of the GNU General Public License
    
    # HISTORY:
    # 2006-02-03 v1.2 - added the -C flag to tar options. Otherwise tar would not 
    #            extract to a dir with different name then the one found in the 
    #            archive.
    
    usage () {
    
    echo >&2 "$NAME_ $VERSION_ - $PURPOSE_
    Usage: $SYNOPSIS_
    Requires: $REQUIRES_
    Options:
         -r, remove the compressed file after extraction
         -v, verbose
         -h, usage and options (help)
         -l, see this script"
        exit 1
    }
    
    # args check
    [ $# -eq 0 ] && { echo >&2 missing argument, type $NAME_ -h for help; exit 1; }
    
    # var init
    rmf=
    verbose=
    
    # option and argument handling
    while getopts vhlr options; do
    
        case $options in
            r) rmf=on ;;
            v) verbose=on ;;
            h) usage ;;
            l) more $0; exit 1 ;;
           \?) echo invalid argument, type $NAME_ -h for help; exit 1 ;;
        esac
    
    done
    shift $(( $OPTIND - 1 ))
    
    mkdirf() {
    
        # usage: fnc <file_prefix> <file>
    
        [ -d $1 ] && { echo "${NAME_}: skipping ${2} - dir ${1} already exist" ; continue; }
        #echo $1
        mkdir $1
    #    [[ $verbose ]] && echo "${NAME_}: unpacking "$2
    }
    
    file_getDirname() {
    
        local _dir="${1%${1##*/}}"
        [ "${_dir:=./}" != "/" ] && _dir="${_dir%?}"
        echo "$_dir"
    
    }
    
    file_getBasename() {
    
        local _name="${1##*/}"
        echo "${_name%$2}"
    
    }
    
    clean() {
    
        # usage <exit_status> <dir_to_rm>
    
        [[ $1 != 0 ]] && rmdir $2 # remove empty dir if unpacking went wrong
        [[ $1 == 0 && $verbose ]] && echo "${NAME_}: unpacking " ${dir}/${a}
        [[ $rmf ]] && rm -f -- $a
    
    }
    
    start_dir=$(pwd)
    
    for a in "$@"; do
    
        cd $start_dir        
        fname=$(file_getBasename $a)
        dir=$(file_getDirname $a)
        cd $dir
        a=$fname
    
        case $a in
    
    
            # zip
            *.[zZ][iI][pP])
                mkdirf ${a/.[zZ][iI][pP]/} $a
                unzip -qq $a -d ${a/.[zZ][iI][pP]/}
                clean $? ${a/.[zZ][iI][pP]/}
                ;;
    
            # tar
            *.[tT][aA][rR])
                mkdirf ${a/.[tT][aA][rR]/} $a
                tar -xf $a -C ${a/.[tT][aA][rR]/}/
                clean $? ${a/.[tT][aA][rR]/}
                ;;
    
            # tgz
            *.[tT][gG][zZ])
                mkdirf ${a/.[tT][gG][zZ]/} $a
                tar -xzf $a -C ${a/.[tT][gG][zZ]/}
                clean $? ${a/.[tT][gG][zZ]/}
                ;;
    
            # tar.gz 
            *.[tT][aA][rR].[gG][zZ])
                mkdirf ${a/.[tT][aA][rR].[gG][zZ]/} $a
                tar -xzf $a -C ${a/.[tT][aA][rR].[gG][zZ]/}/
                clean $? ${a/.[tT][aA][rR].[gG][zZ]/}
                ;;
    
            # tar.bz2
            *.[tT][aA][rR].[bB][zZ]2)
                mkdirf ${a/.[tT][aA][rR].[bB][zZ]2/} $a
                tar -xjf $a -C ${a/.[tT][aA][rR].[bB][zZ]2/}/
                clean $? ${a/.[tT][aA][rR].[bB][zZ]2/}
                ;;
    
            # tar.z
            *.[tT][aA][rR].[zZ])
                mkdirf ${a/.[tT][aA][rR].[zZ]/} $a
                tar -xZf $a -C ${a/.[tT][aA][rR].[zZ]/}/
                clean $? ${a/.[tT][aA][rR].[zZ]/}
                ;;
    
    
            *) echo "${NAME_}: $a not a compressed file or lacks proper suffix" ;;
    
        esac
    
    done
     
  2. iceni60

    iceni60 ( ^o^)

    Joined:
    Jun 29, 2004
    Posts:
    5,116
    here are a couple of graphics programmes i use -

    gcolor2 - GTK+2 Color Selector
    this programme lets you click anyway on the screen with the eyedropper and it then tells you the exact colour of the pixel you clicked on!
    http://gcolor2.sourceforge.net/

    kolourpaint - a clone of the old windows paint programme. for quick graphic edits or picture resizing etc.
    http://kolourpaint.sourceforge.net/

    i took a couple of screenshots to show you exactly what they're about lol

    gcolor2.png

    kolourpaint.png
     
  3. iceni60

    iceni60 ( ^o^)

    Joined:
    Jun 29, 2004
    Posts:
    5,116
    i know you can use a terminal for this, but i like day planner for an alarm -
    http://www.day-planner.org/

    it's very similar to lsalarm
    http://ltsword.allegronetwork.com/?page=7

    i love this programme - Desktop Data Manager.
    it's a clipboard manager for both clipboards. it is also a screenshot app, letting you select which areas you want to take a screenshot of and a download manager too, i think. i just use it for the clipboard manager though.
    http://data-manager.sourceforge.net/

    DDM.jpg

    i disabled the automatic time update, so i added this alias i can run when i want!
    alias update_time='sudo /usr/sbin/ntpdate pool.ntp.org'
     
  4. Beavenburt

    Beavenburt Registered Member

    Joined:
    Dec 17, 2006
    Posts:
    566
    I love the smxi scripts:- http://smxi.org/ for debian and debian based distros. Makes life that bit easier.
     
Loading...
Thread Status:
Not open for further replies.