Short Tip: Create a “bash alias” with an argument

I always check for changes in rpm files. Unfortunately, the command to do so needs some typing:

rpm -q --changelog PACKAGENAME|most

(Btw., most is a replacement for less). The best idea would be to have a bash/zsh/whatever alias with an argument. This is unfortunately difficult or even impossible, but it is quite easy to define a simple function:

rpmch () { rpm -q --changelog "$1"|most;}

Copy that string to your .zshrc or .bashrc and you can easily query the changelog of rpm packages with the command


This of course works for other commands as well.

9 thoughts on “Short Tip: Create a “bash alias” with an argument

  1. Another very useful function working in that way:
    mkcd() { mkdir -p “$1” && cd “$1”; }

  2. Assuming you are using, and putting up with, `most` for the color ability, I suggest adding

    if [[ -x ` which less` ]]
    export LESSCHARSET="utf-8"
        export PAGER="less"
        if [ $terminfo[colors] -ge 8 ]
            export LESS_TERMCAP_mb=$'\E[01;31m'
            export LESS_TERMCAP_md=$'\E[01;31m'
            export LESS_TERMCAP_me=$'\E[0m'
            export LESS_TERMCAP_se=$'\E[0m'
            export LESS_TERMCAP_so=$'\E[01;44;33m'
            export LESS_TERMCAP_ue=$'\E[0m'
            export LESS_TERMCAP_us=$'\E[01;32m'
        export PAGER="more"

    to your RC files

  3. RichH, actually I’m using most because it shows me on which line I am. And it always reminds me how to find the help :)
    Anyway, what would happen when i use the commands above?

Comments are closed.