Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

help for a function and its completion



Hi,

I writed this functions

### functions
#
##################
#extract files eg: ex tarball.tar#
##################
ex () {
    if [ -f $1 ] ; then
        case $1 in
            *.tar.bz2)   tar vxjf $1        ;;
            *.tar.gz)    tar vxzf $1     ;;
            *.bz2)       bunzip2 $1       ;;
            *.rar)       unrar x $1     ;;
            *.gz)        gunzip $1     ;;
            *.tar)       tar vxf $1        ;;
            *.tbz2)      tar vxjf $1      ;;
            *.tgz)       tar vxzf $1       ;;
            *.zip)       unzip $1     ;;
            *.Z)         uncompress $1  ;;
            *.7z)        7z x $1    ;;
            *)           echo "$1 non può essere estratto con ex()" ;;
        esac
    else
        echo "$1 non è un archivio valido"
    fi
}

##################
#compress directory eg: cm tarball.tar tarball#
##################
cm () {
    if [ -d $2 ] ; then
        case $1 in
            *.tar.bz2)   tar vcjf $1 $2        ;;
            *.tar.gz)    tar vczf $1 $2     ;;
            *.bz2)       bunzip2 $1 $2      ;;
#            *.rar)       unrar -e $1 $2     ;;
            *.gz)        gzip $1 $2     ;;
            *.tar)       tar vcf $1 $2        ;;
            *.tbz2)      tar vcjf $1 $2      ;;
            *.tgz)       tar vczf $1 $2       ;;
            *.zip)       zip -r $1 $2     ;;
            *.Z)         compress $1 $2  ;;
            *.7z)        7z a -t7z $1 $2    ;;
            *)           echo "$2 non può essere compresso con cm()" ;;
        esac
    else
        echo "$2 non è un archivio valido"
    fi
}

 	
I tried to understand how to write zstyle completion to make your life
easier but are not very good.

I only wish that when I enter, eg,

cm directory directory.tar

postfix tar appear on a list where there are tar, tar.gz, etc.

Maybe I ask too much but a little help, I would make great strides

	
Thanks



Messages sorted by: Reverse Date, Date, Thread, Author