alias in bash shell for CTRL + l


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers alias in bash shell for CTRL + l
# 1  
Old 03-22-2009
alias in bash shell for CTRL + l

Is it possible to create an alias wherein it will use a keystroke.
Like to clear the screen in bash i have to use CTRL + l.
I want to make an alias 'c' out of this.

Thanks.
# 2  
Old 03-22-2009
CTRL + i gives one a tab character so aliasing it would affect tab as well and vice versa.
# 3  
Old 03-22-2009
Actually its not "CTRL + i" .... it is "CTRL + l" ...... lowercase L
# 4  
Old 03-22-2009
AFAIK you can't alias an keystroke, but you can create an alias for the clear program, eg alais c=`which clear`
# 5  
Old 03-22-2009
Quote:
Originally Posted by pludi
AFAIK you can't alias an keystroke, but you can create an alias for the clear program, eg alais c=`which clear`
just curious, why would we need the "which" command?

if "clear" is in our path, then wouldn't this work:

Code:
alias c='clear'

if "clear" is not in our path, then it is not going to work either way.

Am i missing something? I'm not trying to be a smart@$$, just trying to learn something here.
# 6  
Old 03-22-2009
Sure, it would still work the same. Just a habit of mine to reference programs by their full path.
# 7  
Old 03-22-2009
The main reason to reference the program by it full path, is that many people create aliases for utilities like (i.e l='ls -F' or rm='rm -i' or grep='grep -i') To avoid having a command not work as expected you reference it by it full path. I agree that it is a good habit to get into when working on machines that are accessed by many people.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Send ctrl-C signal using bash script.

declare -a array=( "LLC-load-misses" "LLC-loads" "LLC-store-misses" "LLC-stores" "branch-load-misses" "branch-loads" "dTLB-load-misses" "dTLB-loads" "dTLB-store-misses" "dTLB-stores" "iTLB-load-misses" "iTLB-loads" "branch-instructions" "branch-misses" "bus-cycles" "cache-misses" "cache-references"... (2 Replies)
Discussion started by: BHASKAR JUPUDI
2 Replies

2. Shell Programming and Scripting

Automation of keyboard inputs..like Ctrl+d and Ctrl+a

Hi..! I'm stuck with my automation of starting a process and keeping it running even after the current ssh session has exited.. So i'm trying to use command 'screen'. which is doing exactly what i wanted, But the problem is automation of the same. i will have to press Ctrl+a and Ctrl+d for... (2 Replies)
Discussion started by: chandana hs
2 Replies

3. UNIX for Dummies Questions & Answers

Ctrl-V + Ctrl-J for newline character does not work inside vi editor

Hi friends, I am trying to add a newline char ('\n') between the query and the commit statement in the following shell script. #! /bin/sh echo "select * from tab; commit;" > data.sql I have tried typing in "Ctrl-V + Ctrl-J" combination which has inserted ^@ (NUL) character but the commit... (1 Reply)
Discussion started by: royalibrahim
1 Replies

4. Shell Programming and Scripting

How to handle CTRL+Z or CTRL+C in shells script?

Hi, while executing shell script, in the middle of the process, if we kill the shell script( ctrl+z or ctrl+c), script will be killed and the files which using for the script will be in the folder. How to handle those scenarios. Is there any possibilities, if user breaks the script, I need to... (3 Replies)
Discussion started by: ckchelladurai
3 Replies

5. Shell Programming and Scripting

ctrl-c in bash script - Programming

Hi All, I need to place a ctrl-c interrupt in a bash script, there is no other way, it has to be done :) can someone please advise how would I go about this? i want to use ctrl c in below code, after the code excution of just 1 min or 1sec java Cspsamp 111.19.5.172 7025 rd1... (6 Replies)
Discussion started by: aish11
6 Replies

6. Shell Programming and Scripting

how can I export an alias and use it in any shell that I want to switch to like bash, ksh

None of the aliases that I set are available if I switch to a different shell. How can I export aliases and make them available in any shell that I switch to like ksh or bash ? I tried these $>alias godata='cd /home/kc/app/data' $>alias -x godata='cd /home/kc/app/data' $>alias |... (2 Replies)
Discussion started by: kchinnam
2 Replies

7. Shell Programming and Scripting

Ctrl-C or Ctrl-Z causing exit the session

H! I have written script where it need to invoke the perl script in background, then write the pid in temp file then bring back the job to foreground. whenever the Ctrl-C or Ctrl-Z is pressed in the script has to exit and prompt should be dispalyed. but this script causing exit from shell session... (2 Replies)
Discussion started by: jramesh1
2 Replies

8. UNIX for Dummies Questions & Answers

ctrl-o in bash on os X leopard -- how does it work exactly?

I'm going through "learning the bash shell" by newham and rosenblatt. I'm trying to ctro-O to execute and then go on to the next command in the history list, ctrl-o again, etc. (I'm just trying to get a feel for it in case I want to use it). But ctrl-o does nothing. Can someone help me out as to... (5 Replies)
Discussion started by: Straitsfan
5 Replies

9. UNIX for Dummies Questions & Answers

ctrl+S resulting in (i-search) in bash

Hi On solaris, when I press Ctrl+S on an XTERM, the window normally freezes. But today on the same machine, the Ctrl+S key results in (i-search) !! I understand that it has got something to do with emacs (may be not). But I do not use emacs at all. Other specific keys including <backspace>,... (3 Replies)
Discussion started by: balaji280283
3 Replies

10. AIX

Disable ctrl-c,ctrl-d,ctrl-d in ksh script

I wrote a ksh script for Helpdesk. I need to know how to disable ctrl-c,ctrl-z,ctrl-d..... so that helpdesk would not be able to get to system prompt :confused: (6 Replies)
Discussion started by: wtofu
6 Replies
Login or Register to Ask a Question