LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-16-2007, 02:17 PM   #1
supersubu123
LQ Newbie
 
Registered: Jan 2007
Distribution: Suse 10.2
Posts: 18

Rep: Reputation: 0
Lightbulb Any way to create bash short cuts (like CTRL+l for clear and Ctrl+D for exit)


as the subject says ...
i want to create short cuts for some commands like these ones..
(it shud be possible as Ctrl+l executes the clear command)
Ctrl+Shift+Delete-->ps aux
Ctrl+Left --->cd $OLDPWD
Ctrl+Up--->cd ..
 
Old 05-16-2007, 03:49 PM   #2
xpromisex
Member
 
Registered: Apr 2004
Location: Statesboro, GA
Distribution: Arch Linux 2007.05 "Duke" (Kernel 2.6.21)
Posts: 447

Rep: Reputation: 30
If those keys produce some text (like Ctrl+C produces ^C) You should be able to alias them in your user's .bashrc.

I'm not sure if it is possible and I really can't try at the moment but see if it works.

You can find more information on aliases here:http://www.ss64.com/bash/alias.html
 
Old 05-16-2007, 04:02 PM   #3
sibtay
Member
 
Registered: Aug 2004
Location: U.S
Distribution: Ubuntu
Posts: 145

Rep: Reputation: 15
If you want to do this in a shell script, consider reading user input and then checking their ASCII values. For example ctrl + a = 01 in ASCII and ctrl + b = 02 in ASCII.
 
Old 05-22-2007, 01:03 PM   #4
supersubu123
LQ Newbie
 
Registered: Jan 2007
Distribution: Suse 10.2
Posts: 18

Original Poster
Rep: Reputation: 0
some how i added this line
alias ^E='cd $OLDPWD' but when exectued it says
bash: ./file_name: cannot execute binary file
and Mr.Sibtay i have no idea to write a script for this pls guide me
 
Old 05-28-2007, 09:26 PM   #5
sibtay
Member
 
Registered: Aug 2004
Location: U.S
Distribution: Ubuntu
Posts: 145

Rep: Reputation: 15
Quote:
Originally Posted by supersubu123
some how i added this line
alias ^E='cd $OLDPWD' but when exectued it says
bash: ./file_name: cannot execute binary file
and Mr.Sibtay i have no idea to write a script for this pls guide me
Alright here is the solution. In order to bind keys in bash you need to add entries for those bindings in the /etc/inputrc file. For example the following entry maps CTRL-o to cd $OLDPWD

"\C-o": 'cd $OLDPWD\n'

Similarly the following entry would bind CTRL-l to ls:

"\C-l": 'ls\n'

Hope this helps.
 
Old 05-30-2007, 03:02 AM   #6
supersubu123
LQ Newbie
 
Registered: Jan 2007
Distribution: Suse 10.2
Posts: 18

Original Poster
Rep: Reputation: 0
great..adding lines to /etc/inputrc worked ...thanks..
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ctrl+c & ctrl+v equivalent for Gnome terminal window? halfpower Linux - General 2 11-29-2005 02:57 AM
10.0 RC1 logout out from KDE needs CTRL-Z to exit 1kyle SUSE / openSUSE 0 09-23-2005 04:01 AM
no ctrl-a or ctrl-z in emacs or on command line? ashlock Fedora 5 12-30-2003 08:00 PM
ctrl+ c ctrl +v not working in windows xp Astro General 3 10-20-2003 08:42 PM
You may now exit and restart using ctrl-alt-delete ... I wish! pbhj Slackware 4 12-06-2002 04:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration