Results 1 to 5 of 5

Thread: Dict Alias/ Function

  1. #1
    Join Date
    Feb 2011
    Location
    127.0.0.1
    Posts
    472

    Default Dict Alias/ Function

    I'm using the dict application to query dictionary entries from CLI. I would like to create an alias/ function to execute
    Code:
    dict <argument/word I'm looking for> | less
    , and since it's a variable, it seems that an alias can't be created...and I'm not very good at functions. I don't like to pipe less for every query.
    Reliable + rider = RiDeR PlUs
    ...if you find this helpful, click on the star below...
    +-+ +-+
    |r| |+|
    +-+ +-+

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,869

    Default Re: Dict Alias/ Function

    I would have posted this in the Programming/Scripting subforums. That is where the appropriate gurus are waiting eagerly for pogramming and scripting questions.

    Make (editor of your choice) a file in the bin directory inside your home directory with the contents (you choose a name, in this example I call it riderdict):
    Code:
    #!/bin/bash
    dict ${1} | less
    Then make this file executable for the owner
    Code:
    chown u+x ${HOME}/riderdict
    From now on you can just call
    Code:
    riderdict monkey
    Henk van Velden

  3. #3
    Join Date
    Feb 2011
    Location
    127.0.0.1
    Posts
    472

    Default Re: Dict Alias/ Function

    Cool. Thanks, hcvv. So there was no need to edit .bashrc.
    Reliable + rider = RiDeR PlUs
    ...if you find this helpful, click on the star below...
    +-+ +-+
    |r| |+|
    +-+ +-+

  4. #4
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,869

    Default Re: Dict Alias/ Function

    Quote Originally Posted by riderplus View Post
    Cool. Thanks, hcvv. So there was no need to edit .bashrc.
    This solution requires no chang of .bashrc. BTW, when you want to add an alias (they have there value), then add them to .alias (to be created when you add your first alias). You have them then nice together in one file and .bashrc adds that (see one of the last lines there):
    Code:
    test -s ~/.alias && . ~/.alias || true
    But making a small script with often to be done tasks in your bin is a good solution.
    Henk van Velden

  5. #5
    Join Date
    Feb 2011
    Location
    127.0.0.1
    Posts
    472

    Default Re: Dict Alias/ Function

    Quote Originally Posted by hcvv View Post
    BTW, when you want to add an alias (they have there value), then add them to .alias (to be created when you add your first alias). You have them then nice together in one file and .bashrc adds that (see one of the last lines there):
    Code:
    test -s ~/.alias && . ~/.alias || true
    But making a small script with often to be done tasks in your bin is a good solution.
    Great hints! Itøs better to use my ~/bin folder, it was empty anyway
    Reliable + rider = RiDeR PlUs
    ...if you find this helpful, click on the star below...
    +-+ +-+
    |r| |+|
    +-+ +-+

Tags for this Thread

Posting Permissions

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