readline

search for more blogs here

 

"Bash Emacs Editing Mode Cheat Sheet" posted by ~Ray
Posted on 2008-11-13 12:19:41

When you are working in a shell you certainly don’t want to waste your time using arrow keys or home/end keys to navigate around the command line. One of the most popular shells. - Bourne Again SHell uses library for reading the command line. The GNU Readline library provides a set of functions for use by applications that allow users to edit command lines as they are typed in. The readline library also includes functions to maintain a list of previously-entered command lines to recall and perhaps reedit those lines and perform -like history expansion on previous commands. Both emacs and vi editing modes are available. I have mastered both of the editing modes and have created cheat sheets for both of them (and a tiny separate one for readline’s history expansion). This is a cheat sheet for the default emacs editing mode. Here are a few examples with screenshots on how to use this editing mode. Let ‘[]‘ be the position of cursor in all the examples. Suppose you are at the end of the line and want to move 3 words backwards. An alternative is to hit M-b three times in a row: M-b M-b M-b If you look up on the cheat sheet what M-3 does it sets the numeric-argument to 3 which in this case acts as a counter how many times should M-b command be repeated. The M-b command calls backward-word function which does the obvious. The numeric-argument can also be negative which makes the argument to be applied in the opposite direction. Other shortcuts of interest are M-f to move forward and C-a and C-e to move to the beginning and end of line. Suppose you used a pretty complex command a while ago and now you remember just a few arguments of this command. You want to find this command and call it with a few arguments modified. If you hit C-r readline will put you in an incremental reverse history search mode. Typing a part of the arguments you remember will locate the previously executed command matching the typed text. Hitting C-r again will locate any other command which matches your typed text. To put the found command on command line for editing hit C-j. Suppose you want to quickly list all the users on the system. Hit C-x ~ and read-line will attempt username completion and output all the usernames to the terminal. $ []adm catonmat ftp halt mailnull nobody root smmsp vcsaapache cpanel games lp mysql nscd rpc sshdbin daemon gopher mail named operator rpm synccat dbus haldaemon mailman news picurls shutdown uucp$ [] Suppose you now want to quickly list all the users on the system starting with ‘m’. You can type ‘m’ followed by the same C-x ~ to do that. Suppose you have to type a-long-word-like-this a couple of times. The easiest way to do this is to kill the word which puts it into the kill ring. Contents of the kill ring can be accessed by yanking. For example type ‘a-long-word-like-this’ in the shell: Press C-y to yank (paste) the word as many times as you wish (I pressed it 3 times here:) $ command a-long-word-like-this a-long-word-like-this a-long-word-like-this [] The kill ring does not contain just the one latest killing. It can be filled with a number of kills and rotated with M-y shortcut. Suppose you typed a longer command and you noticed that part of the THE TEXT GOT TYPED IN CAPITAL LETTERS. Without knowing the readline shortcuts you would erase the text and probably type it again. Now you can use the readline keyboard shortcuts and change the case very very quickly. You can use the following shortcuts to accomplish this: 1) M-l (Meta-l (on your computer probably ESC-l)) shortcut is bound to readline’s downcase-word function which lowercases the current word.2) M-b shortcut is bound to readline’s backward-word function which moves the cursor one word backwards.3) M- shortcut is bound to readline’s numeric-argument function which in some cases acts as how many times should the following command be repeated. Here is a real word example suppose we have typed the following ([] is the cursor): $ echo the text. THE TEXT GOT TYPED IN CAPITAL LETTERS[] To get to the beginning of ‘THE’ we might repetitively hit M-b seven times or we could set the numeric argument to seven by typing M-7 and then hit M-b once. After doing this the cursor would have moved before the word ‘THE’: $ echo the text. []THE TEXT GOT TYPED IN CAPITAL LETTERS Now by setting the numerical argument to 7 again and by pressing M-l or by pressing M-l seven times we turn the text all in lower case. $ echo the text the text got typed in capital letters[] Actually what we did in this example was not as efficient as it could have been. The numeric-argument shortcut accepts negative arguments which turn the direction of the following command in other direction. We could have turned the text in lower case by hitting M--7 and M-l If you really want to be more productive. I suggest you play around with the commands in the cheat sheet for a while. My previous article on being more productive on the command line was which allows to emulate multiple terminals in a single window. You can take a look at it as well! ASCII txt format:Download link: Downloaded: 2047 times LaTeX format ( tex):Download link: Downloaded: 854 times This cheat sheet is released under GNU Free Document License. Ankush it will not be the vi (editor) cheat sheet! It will be a cheat sheet for vi keyboard bindings when working with bash! As I said in the article bash uses readline library to get input from you. When you type something (for example a command ‘ls -las’) it’s the readline library that gets this text for you. The library has two editing modes - emacs mode and vi mode. Each of these modes has its own keyboard shortcuts for doing stuff like moving a word back clearing the whole line etc. The next one is going to be a cheat sheet for vi mode. Uhh. ‘Rubout’? I guess you should have clarified on this because I realized it was the backspace only after several-seconds-long intense staring at the backwards-delete-char line. 8=]Curiously the Wikipedia page about Rubout redirects to Delete. Go figure. You could have copy-pasted the page from the bash manual instead of the readline man page……you wouldn’t have missed the other completion keys… Also unbound functions on a cheat sheet what’s the point? I guess it’s too much work…like acknowledging the copyrights of these manual pages…. * C-x / which does filename completion. * C-x $ which does bash variable completion. * C-x @ which does hostname completion and. * C-x ! which does command completion. Bleh the unbound keys are there so people knew they existed and could re-map them. Also if you look carefully enough you will notice it is released under GNU FDL the same license as readline man page. I did not include those keys you listed in the cheat sheet because I ran out of space there. So I left them out… Great stuff! I can’t count how much more quickly I could have finished my PhD if I’d only known (or rather be bothered to look up) shortcuts like this. […] Bash provides two modes for command line editing - emacs and vi. Emacs editing mode is the default and I already wrote an article and created a cheat sheet for this mode. […] * C-x / which does filename completion. * C-x $ which does bash variable completion. * C-x @ which does hostname completion and. * C-x ! which does command completion. They just show possible completions. The actual completions are done with Meta key + / or $ or @ or ! respectively. […] efficiently in bourne again shell. Previously I have written on how to work efficiently in vi and emacs command editing modes by using predefined keyboard shortcuts (both articles come with cheat sheets […] I was happy to see it later:1) M-l (Meta-l (on your computer probably ESC-l)) shortcut is bound to readline’s downcase-word function which lowercases the current word. M- cycles through previous commands’ last argument. This page pushed me to try and learn bash shortcuts and as a result. I got faster and more efficient. Thanks oh and cjk those are good to know but the ones in the cheat sheet concentrate on letters and keys that are centered on the main chunk of the keyboard. By using the letters and stuff near them you get to move your hands around the keyboard less often which makes you operate faster XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <pre> <em> <i> <strike> <strong> : Hi Varish…you are really helping all by describing the right way to do things thanks so much…...

Forex Groups - Tips on Trading

Related article:
http://www.catonmat.net/blog/bash-emacs-editing-mode-cheat-sheet/

comments | Add comment | Report as Spam


"is.readLine() deprecation error (Socket Programming) in Java" posted by ~Ray
Posted on 2008-03-12 23:10:52

conceive of. In. Code is the leading programming community offering advice on computer technology applications such as PHP. Java and Microsoft's ASP. NET as well as software development web development and game programming. import java io.*;import java net.*;public class smtpClient { public static void main(arrange[] args) {// declaration section:// smtpClient: our client socket// os: create stream// is: input stream Socket smtpSocket = null; DataOutputStream os = null; DataInputStream is = null;// Initialization divide:// Try to open a socket on turn 25// Try to open input and create streams try { smtpSocket = new Socket("hostname". 25); os = new DataOutputStream(smtpSocket getOutputStream()); is = new DataInputStream(smtpSocket getInputStream()); } catch (UnknownHostException e) { System err println("Don't know about host: hostname"); } catch (IOException e) { System err println("Couldn't get I/O for the connection to: hostname"); }// If everything has been initialized then we want to create verbally some data// to the socket we have opened a connection to on turn 25 if (smtpSocket != null && os != null && is != null) { try {// The capital arrange before each colon has a special meaning to SMTP// you may want to construe the SMTP specification. RFC1822/3 os writeBytes("HELO\n"); os writeBytes("send From: k3is@fundy csd unbsj ca\n"); os writeBytes("RCPT To: k3is@fundy csd unbsj ca\n"); os writeBytes("DATA\n"); os writeBytes("From: k3is@fundy csd unbsj ca\n"); os writeBytes("Subject: testing\n"); os writeBytes("Hi there\n"); // communicate be os writeBytes("\n.\n"); os writeBytes("QUIT");// keep on reading from/to the socket till we receive the "Ok" from SMTP,// once we received that then we want to break. String responseLine; while ((responseLine = is readLine()) != null) { System out println("Server: " + responseLine); if (responseLine indexOf("Ok") != -1) { end; } }// clean up:// close the create stream// change state the enter stream// close the socket os close(); is close(); smtpSocket close(); } catch (UnknownHostException e) { System err println("Trying to cerebrate to unknown host: " + e); } catch (IOException e) { System err println("IOException: " + e); } } } } It is right on the documentation located at the URL below. It gives you what to replace it with and an example. Just lookup readline() to construe all about it. apply! So simple. I can't accept that I took a course on Java with the compilier I'm using I'm using and they never pointed that out. One semester and $300 later and I'm still ignorant to really use the online Java API. I've always disliked Georgia Southern. I probably should have just enrolled at </dic>. Thanks!

Forex Groups - Tips on Trading

Related article:
http://www.dreamincode.net/forums/showtopic35731.htm

comments | Add comment | Report as Spam


"is.readLine() deprecation error (Socket Programming) in Java" posted by ~Ray
Posted on 2008-03-12 23:10:52

Dream. In. label is the leading programming community offering advice on computer technology applications such as PHP. Java and Microsoft's ASP. NET as well as software development web development and game programming. import java io.*;import java net.*;public categorise smtpClient { public static void main(String[] args) {// declaration section:// smtpClient: our client socket// os: create stream// is: input stream Socket smtpSocket = null; DataOutputStream os = null; DataInputStream is = null;// Initialization divide:// Try to open a socket on port 25// Try to change state input and output streams try { smtpSocket = new Socket("hostname". 25); os = new DataOutputStream(smtpSocket getOutputStream()); is = new DataInputStream(smtpSocket getInputStream()); } catch (UnknownHostException e) { System err println("Don't know about entertain: hostname"); } surprise (IOException e) { System err println("Couldn't get I/O for the connection to: hostname"); }// If everything has been initialized then we be to create verbally some data// to the socket we have opened a connection to on port 25 if (smtpSocket != null && os != null && is != null) { try {// The capital string before each colon has a special meaning to SMTP// you may be to construe the SMTP specification. RFC1822/3 os writeBytes("HELO\n"); os writeBytes("MAIL From: k3is@fundy csd unbsj ca\n"); os writeBytes("RCPT To: k3is@fundy csd unbsj ca\n"); os writeBytes("DATA\n"); os writeBytes("From: k3is@fundy csd unbsj ca\n"); os writeBytes("Subject: testing\n"); os writeBytes("Hi there\n"); // message body os writeBytes("\n.\n"); os writeBytes("QUIT");// keep on reading from/to the socket till we receive the "Ok" from SMTP,// once we received that then we be to break. String responseLine; while ((responseLine = is readLine()) != null) { System out println("Server: " + responseLine); if (responseLine indexOf("Ok") != -1) { break; } }// clean up:// close the create be adrift// close the input stream// close the socket os close(); is change state(); smtpSocket change state(); } surprise (UnknownHostException e) { System err println("Trying to cerebrate to unknown host: " + e); } catch (IOException e) { System err println("IOException: " + e); } } } } It is right on the documentation located at the URL below. It gives you what to replace it with and an example. Just lookup readline() to construe all about it. Enjoy! So simple. I can't accept that I took a cover on Java with the compilier I'm using I'm using and they never pointed that out. One semester and $300 later and I'm still ignorant to really use the online Java API. I've always disliked Georgia Southern. I probably should have just enrolled at </dic>. Thanks!

Forex Groups - Tips on Trading

Related article:
http://www.dreamincode.net/forums/showtopic35731.htm

comments | Add comment | Report as Spam


"shogun-readline" posted by ~Ray
Posted on 2008-01-01 21:15:49

SHOGUN - is a new machine learning toolbox with focus on large scale kernel methods and especially on give Vector Machines (SVM) with focus to bioinformatics. It provides a generic SVM object interfacing to several different SVM implementations. Each of the SVMs can be combined with a variety of the many kernels implemented. It can deal with weighted linear combination of a number of sub-kernels each of which not necessarily working on the same domain where an optimal sub-kernel weighting can be learned using Multiple Kernel Learning. Apart from SVM 2-class classification and regression problems a number of linear methods like Linear Discriminant Analysis (LDA). Linear Programming Machine (LPM). (Kernel) Perceptrons and also algorithms to train hidden markov models are implemented. The enter feature-objects can be dense sparse or strings and of type int/short/double/char and can be converted into different feature types. Chains of preprocessors (e g substracting the convey) can be attached to each feature object allowing for on-the-fly pre-processing. SHOGUN comes in different flavours a stand-a-lone version and also with interfaces to Matlab(tm). R. Octave. Readline and Python. This is the Readline package.

Forex Groups - Tips on Trading

Related article:
http://potd.redsymbol.net/?p=shogun-readline

comments | Add comment | Report as Spam


"Readline on OS X for trunk build" posted by ~Ray
Posted on 2007-12-15 15:03:37

Just got the trunk out of svn to build 2.6 alpha on OS X 10.4(Tiger). No readline. I can't remember what I did to get it when I built 2.5 but it works there. Google searches are bringing up what to do for the Python 2.3 that comes with OS X 10.4. Could someone point me in the right direction? Thanks. James --

Forex Groups - Tips on Trading

Related article:
http://www.gossamer-threads.com/lists/python/python/598408

comments | Add comment | Report as Spam


"Readline on OS X for trunk build" posted by ~Ray
Posted on 2007-12-09 13:37:55

Just got the trunk out of svn to create 2.6 alpha on OS X 10.4(Tiger). No readline. I can't remember what I did to get it when I built 2.5but it works there. explore searches are bringing up what to do for thePython 2.3 that comes with OS X 10.4. Could someone point me in theright direction?Thanks,James. . happening on trunk by looking at a branch. ... I don't think there is a wayto do that in Subversion right now. .. or do you need 'svn shift' on each.. really is an ancient African evince for "I am sick of compiling Gentoo". ... (freebsd-arch) .. Tag 0.4.2 for BCF use.. happening on trunk by looking at a grow... or do you need 'svn shift' on each... (freebsd-arch) .. I am working on Linux and I have the latest version from svn. ... After I../configureand make I can run python but the readline give is not there. ... (comp lang python)

Forex Groups - Tips on Trading

Related article:
http://coding.derkeiler.com/Archive/Python/comp.lang.python/2007-10/msg03335.html

comments | Add comment | Report as Spam


"Readline on OS X for trunk build" posted by ~Ray
Posted on 2007-12-09 13:37:54

Just got the trunk out of svn to create 2.6 alpha on OS X 10.4(Tiger). No readline. I can't bequeath what I did to get it when I built 2.5but it works there. explore searches are bringing up what to do for thePython 2.3 that comes with OS X 10.4. Could someone inform me in theright direction?Thanks,James. . happening on trunk by looking at a branch. ... I don't think there is a wayto do that in Subversion right now. .. or do you need 'svn shift' on each.. really is an ancient African evince for "I am sick of compiling Gentoo". ... (freebsd-arch) .. Tag 0.4.2 for BCF use.. happening on trunk by looking at a branch... or do you need 'svn remove' on each... (freebsd-arch) .. I am working on Linux and I undergo the latest version from svn. ... After I../configureand make I can run python but the readline support is not there. ... (comp lang python)

Forex Groups - Tips on Trading

Related article:
http://coding.derkeiler.com/Archive/Python/comp.lang.python/2007-10/msg03335.html

comments | Add comment | Report as Spam


 

 




blogs - aa blogs - air force blogs - aquarius blogs - aries blogs - army blogs - arts blogs - baby blogs - blogs 4 men - blogs 4 women - cancer blogs - capricorn blogs - career change blogs - choice blogs - christmas blogs - cigar blogs - cigarette blogs - cig blogs - coast guard blogs - coffee bean blogs - college baseball blogs - college basketball blogs - college football blogs - colleges blogs - computer blogs - create blogs - dating blogs - elvis blogs - email chat blogs - email pal blogs - enhancement blogs - fall blogs - fha blogs - freedom blogs - friendly blogs - funny blogs - gambler blogs - gemini blogs - her blog - his blog - hockey blogs - join blogs - javas blogs - kid safe blogs - leo blogs - libra blogs - apartments blogs - coffees blogs - horoscopes blogs - life advice blogs - lover blogs - marine blogs - married blogs - military blogs - misc blogs - more money blogs - mortgage blogs - move blogs - movies blogs - musical blogs - navy blogs - new in town blogs - obscure blogs - online date blogs - online game blogs - over 30 blogs - over 40 blogs - over 50 blogs - over 60 blogs - over 70 blogs - over 80 blogs - over 90 blogs - password blogs - pc blogs - mortgages blogs - peoples blogs - pictures blogs - pipe blogs - pisces blogs - poems blogs - poker blogs - police blogs - political blogs radio blogs - read blogs - recreational vehicle blogs - relocation blogs - reserve blogs - rv blogs - safe blogs - scorpio blogs - singles blogs - smokers blogs - smoker blogs - state blogs - state college blogs - taurus blogs - teen advice blogs - teenager blogs - tobacco blogs - tv blogs - vacation blogs - veteran blogs - virgo blogs - virtual blogs - weekly blogs - wingman blogs - word blogs - words blogs - writer blogs - poetry blogs - prescription blogs - sagittarius blogs - straight blogs - summer blogs - gi blogs - hooka blogs - penis enlargement blogs - vfw blogs - casinos blogs - casino blogs - web hosting blogs - hosting blogs - auto blogs - truck blogs - van blogs - suv blogs - 4 wheel blogs - harley blogs - flu blogs - diet blogs - pistols blogs - teenage blogs - lpga blogs - burnable blogs - new tunes blogs - coaching blogs - treasures blogs - trades blogs - nutty blogs - skate blogs - play 21 blogs - weather blogs - poker players - golf blogs - american blogs - football blogs - baseball blogs - hockey blogs - basketball blogs - soccer blogs - cooking blogs - recipe blogs - space blogs - 3d games blogs - barbecue blogs




the readline archives:

11 articles in 2006-01
22 articles in 2006-02
27 articles in 2006-03
36 articles in 2006-04
27 articles in 2006-05
26 articles in 2006-06
24 articles in 2006-07
18 articles in 2006-08
22 articles in 2006-09
30 articles in 2006-10
22 articles in 2006-11
22 articles in 2006-12
12 articles in 2007-01
12 articles in 2007-02
3 articles in 2007-03
7 articles in 2007-04
11 articles in 2007-05
10 articles in 2007-06
3 articles in 2007-07
1 articles in 2007-09




next page


readline