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

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.

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):


#!/bin/bash
dict ${1} | less

Then make this file executable for the owner

chown u+x ${HOME}/riderdict

From now on you can just call

riderdict monkey

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):

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 :slight_smile: