Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: HOWTO Save a few seconds of your life with alias

  1. #1
    Join Date
    Nov 2005
    Beans
    61
    Distro
    Kubuntu 6.10 Edgy
    If you're a command line user like myself no doubt the hassle of typing:

    Code:
    sudo apt-get install package
    everytime you want to grab a package causes you strife. Let aliases help.

    At a shell simply type:

    Code:
    alias apt='sudo apt-get install'
    alias remove='sudo apt-get remove'
    alias search='apt-cache search'
    from now on you can simply type:

    Code:
    apt package
    to install a package.

    Code:
    remove package
    to remove a package.

    and, you've guessed it:

    Code:
    search package
    to look for a package.

    To make these aliases stick add entries for them in your .bashrc or .bash_profile files.

    Of coures you don't have to use my shortcuts, perhaps you'd prefer apt-search for search it's up to you such is the power of aliases. It should be noted that 'install' is already a command in Linux hence my choice of 'apt'.

    cg
    Last edited by closet geek; November 14th, 2005 at 12:31 PM.
    Registered Linux user: 311835

  2. #2
    Join Date
    Jan 2005
    Location
    Signa, Florence
    Beans
    255
    Distro
    Hardy Heron (Ubuntu Development)

    Re: HOWTO Save a few seconds of your life with alias

    very useful...

    cool!

    thnx man!
    iAc alias Lizardking - Ubuntu Artwork Team
    web: www.iacopomasi.net
    mail: iacopo.masi@gmail.com

  3. #3
    Join Date
    Mar 2005
    Beans
    6,040

    Re: HOWTO Save a few seconds of your life with alias

    To make these permanent you can put the alias lines to your ~/.bash_profile file.
    Previously known as 23meg

  4. #4
    Join Date
    Apr 2005
    Location
    Sintra, Portugal
    Beans
    835

    Exclamation Re: HOWTO Save a few seconds of your life with alias

    Code:
    alias apt='sudo apt-get install'
    alias remove='sude apt-get remove'
    alias search='apt-cache search'
    You have an error there. It should be sudo. Just for the sake of not misleading Ubuntu newcomers.

    Apart from that, great tip. Thanks.

  5. #5
    Join Date
    Nov 2005
    Beans
    61
    Distro
    Kubuntu 6.10 Edgy

    Re: HOWTO Save a few seconds of your life with alias

    Quote Originally Posted by henriquemaia
    Code:
    alias apt='sudo apt-get install'
    alias remove='sude apt-get remove'
    alias search='apt-cache search'
    You have an error there. It should be sudo. Just for the sake of not misleading Ubuntu newcomers.

    Apart from that, great tip. Thanks.
    Oops! It should be no great suprise I also have:

    Code:
    alias sude='sudo'
    In my bash_profile

    cg
    Registered Linux user: 311835

  6. #6
    Join Date
    Jun 2005
    Beans
    110
    Distro
    Ubuntu Breezy 5.10

    Re: HOWTO Save a few seconds of your life with alias

    Quote Originally Posted by closet geek
    If you're a command line user like myself no doubt the hassle of typing:

    Code:
    sudo apt-get install package
    everytime you want to grab a package causes you strife. Let aliases help.

    At a shell simply type:

    Code:
    alias apt='sudo apt-get install'
    alias remove='sudo apt-get remove'
    alias search='apt-cache search'
    from now on you can simply type:

    Code:
    apt package
    to install a package.

    Code:
    remove package
    to remove a package.

    and, you've guessed it:

    Code:
    search package
    to look for a package.

    To make these aliases stick add entries for them in your .bashrc or .bash_profile files.

    Of coures you don't have to use my shortcuts, perhaps you'd prefer apt-search for search it's up to you such is the power of aliases. It should be noted that 'install' is already a command in Linux hence my choice of 'apt'.

    cg

    Quote Originally Posted by closet geek
    If you're a command line user like myself no doubt the hassle of typing:

    Code:
    sudo apt-get install package
    everytime you want to grab a package causes you strife. Let aliases help.

    At a shell simply type:

    Code:
    alias apt='sudo apt-get install'
    alias remove='sudo apt-get remove'
    alias search='apt-cache search'
    from now on you can simply type:

    Code:
    apt package
    to install a package.

    Code:
    remove package
    to remove a package.

    and, you've guessed it:

    Code:
    search package
    to look for a package.

    To make these aliases stick add entries for them in your .bashrc or .bash_profile files.

    Of coures you don't have to use my shortcuts, perhaps you'd prefer apt-search for search it's up to you such is the power of aliases. It should be noted that 'install' is already a command in Linux hence my choice of 'apt'.

    cg
    I think I missed something. I can use the aliases after entering them into terminal, but they no longer work after reboot. Here's my .bash profile:

    # .bash_profile
    alias purge='sudo aptitude purge'
    alias apt='sudo apt-get install'
    alias edit='sudo gedit'

    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
    . ~/.bashrc
    fi


    # User specific environment and startup programs

    PATH=$PATH:$HOME/bin

    export PATH
    unset USERNAME

    -Keep in mind I added my aliases under EVERY section of this file. When I try running any of them (ex. purge gedit) I get 'command not found'. Can someone post theirs to compare?
    Working on it...

  7. #7

    Re: HOWTO Save a few seconds of your life with alias

    Hmmm... try this method.
    Code:
    gedit .bashrc
    Then find this section
    Code:
    # Alias definitions.
    # You may want to put all your additions into a separate file like
    # ~/.bash_aliases, instead of adding them here directly.
    # See /usr/share/doc/bash-doc/examples in the bash-doc package.
    
    #if [ -f ~/.bash_aliases ]; then
    #   . ~/.bash_aliases
    #fi
    Uncomment (erase the #) the last three lines of that section. Then do
    Code:
    gedit .bash_aliases
    and add your aliases to that file there. Then type
    Code:
     bash
    to restart bash and make it read your new aliases.

  8. #8
    Join Date
    Jun 2005
    Beans
    110
    Distro
    Ubuntu Breezy 5.10

    Re: HOWTO Save a few seconds of your life with alias

    Quote Originally Posted by souled
    Hmmm... try this method.
    Code:
    gedit .bashrc
    Then find this section
    Code:
    # Alias definitions.
    # You may want to put all your additions into a separate file like
    # ~/.bash_aliases, instead of adding them here directly.
    # See /usr/share/doc/bash-doc/examples in the bash-doc package.
    
    #if [ -f ~/.bash_aliases ]; then
    #   . ~/.bash_aliases
    #fi
    Uncomment (erase the #) the last three lines of that section. Then do
    Code:
    gedit .bash_aliases
    and add your aliases to that file there. Then type
    Code:
     bash
    to restart bash and make it read your new aliases.
    Hmm, 'gedit .bashrc' pulls up:

    # .bashrc

    # User specific aliases and functions

    # Source global definitions
    if [ -f /etc/bashrc ]; then
    . /etc/bashrc
    fi

    Doesn't seem to match your instructions. I'm guessing I missed something else? Thanks for your help so far.
    Working on it...

  9. #9
    Join Date
    Jun 2005
    Beans
    110
    Distro
    Ubuntu Breezy 5.10

    Re: HOWTO Save a few seconds of your life with alias

    Quote Originally Posted by escobar
    Hmm, 'gedit .bashrc' pulls up:

    # .bashrc

    # User specific aliases and functions

    # Source global definitions
    if [ -f /etc/bashrc ]; then
    . /etc/bashrc
    fi

    Doesn't seem to match your instructions. I'm guessing I missed something else? Thanks for your help so far.
    *bump*
    Working on it...

  10. #10

    Re: HOWTO Save a few seconds of your life with alias

    I'm pretty sure you can add those three lines to your .bashrc that I had.

    Or just add the whole section, just uncomment the last three lines. Leave the description commented if you decide to put it in your .bashrc.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •