Results 1 to 5 of 5

Thread: Making long command lines into custom lines?

  1. #1
    Join Date
    Apr 2012
    Location
    Missouri, USA
    Beans
    84
    Distro
    Ubuntu

    Making long command lines into custom lines?

    Okay, so my question is, is it possible to make a very long (or any length) command into whatever you like, as in a phrase? I know you can do it in python, but can you do it for ubuntu's terminal command? I would like to shorten a rather lengthing command into a short word, or word phrase. I run a uTorrent server, and i usually have to start it by entering the command to start the internal server. for this, i have to go to a web page, copy and paste it into terminal. So, instead of putting the command, put something like "start utorrent' and it executes the command?
    Last edited by linux junkie; May 27th, 2013 at 05:59 AM.

  2. #2
    Join Date
    Jun 2007
    Location
    Arizona U.S.A.
    Beans
    1,670

    Re: Making long command lines into custom lines?

    create an alias for your command.

  3. #3
    Join Date
    Apr 2011
    Location
    Mystletainn Kick!
    Beans
    4,710
    Distro
    Ubuntu

    Re: Making long command lines into custom lines?

    Yep, bash_aliases is the way to go.

    If you don't have one already make a file called .bash_aliases in your home folder. then write an alias
    Code:
    alias nameyouwilluse='the-command-that-is-super-long-that-the-alias-will-write'
    Then save.
    Open up a terminal and if any errors were made it'll tell you off the bat.
    Then test it out.
    Splat Double Splat Triple Splat
    Earn Your Keep
    Don't mind me, I'm only passing through.
    Once in a blue moon, I'm actually helpful
    .

  4. #4
    Join Date
    May 2009
    Location
    Courtenay, BC, Canada
    Beans
    1,661

    Re: Making long command lines into custom lines?

    or enter it into the shell before saving it in the file, then you can test it out right away, such as
    Code:
    $ alias test="echo it works really"
    $ test well
    it works really well
    keep in mind that an alias can onoy accept input at the end, so if you want to reference it before that, you have to use a bash script or define a function, but it can still be useful. here's my tracksearch alias to search mpd's current playlist for a song
    Code:
    alias tracksearch="alias tracksearch; mpc playlist -f '%position%. (%time%) %artist%: %album% -  %title%' | grep -iE"
    lets me do something like:
    http://imageshack.us/a/img541/8539/s...3052600041.png

  5. #5
    Join Date
    Apr 2012
    Location
    Missouri, USA
    Beans
    84
    Distro
    Ubuntu

    Re: Making long command lines into custom lines?

    Awesome! Thanks guys, it worked!!

Tags for this Thread

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
  •