Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How can I create an alias in .bashrc for Kate editor, in order not to write kate file1 file2, but k file1 file2 for opening those files.

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

Add alias k='kate'. Here is a link to some more information on bash aliases.

You can't pass a parameter into an alias. You can do the cd dir_name"=>"cd dir_name; ls -l with a function and an alias like so

mcd () { cd "$1" && ls -l; }
alias cd='mcd'

That will only execute the ls -l if the cd is successful.

share|improve this answer
    
ok and how I can alias "cd dir_name"=>"cd dir_name; ls -l" –  Narek Feb 3 '11 at 12:00
    
Thanks a lot!!! –  Narek Feb 3 '11 at 12:43
add comment

Alias is not safe and flexible. I always use the function.

$c() { cat $*; }
$b() { cd "$1" && ls -l; }
$ b /tmp
total 0
share|improve this answer
    
I have not seen it marked depreciated anywhere, although gnu.org/software/bash/manual/html_node/Aliases.html does suggest shell functions over them –  charlesbridge Feb 3 '11 at 12:35
    
    
man bash "For almost every purpose, aliases are superseded by shell functions" –  alvosu Feb 3 '11 at 12:47
    
The key words are "almost" and "superseded" (the latter is not a synonym for "deprecated"). –  Dennis Williamson Feb 3 '11 at 15:45
    
This is recommendation. I don't recommend use let, alias, select in bash. A change 'deprecated' to 'not safe and flexible'. –  alvosu Feb 3 '11 at 16:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.