How to support this blog?

To support this blog, you can hire me as an OmegaT consultant/trainer, or you can send translation and project management jobs my way.

Search the site:

Bash (command line) shortcuts

Until today, I only used the following shortcuts on the command line:

  • ctrl+a → go to beginning of line
  • ctrl+e → go to end of line
  • ctrl+k → delete to end of line

And even though I was very frustrated by the fact that I had to use the mouse to select/copy/paste etc, it never really occured to me to google for "bash command line shortcuts"...

To make it short: bash uses the readline library.

The user documentation for readline is at:
http://cnswww.cns.cwru.edu/php/chet/readline/rluserman.html

All the shortcuts that exist on your machine can be found by using the 'bind' command:
$ bind -P | more

You'll have more shortcuts with:
$ bind -p | more

If you want to know how to use 'bind' to add shortcuts, check its help file:
$ help bind

Select/cut/paste require to first bind a shortcut to "kill-region":
$ bind "\C-xx": kill-region
(ctrl+x followed by x)

Now we need to select the string (create a "region").

A region is automatically created between a "mark" and the cursor. So, we only need to put the mark at one end of the region and to move the cursor to the other end.

To create a mark use: ctrl+@ or ctrl+space, then move the cursor, then hit ctrl+xx to "kill" the region.

Pasting requires ctrl+y.

But, the ctrl-y (Yank/paste) command works only within the application from where the string was "killed". The "kill-ring" is not shared by other applications (even though they may accept ctrl-y as a Yank command).

So, if you want to get a string from terminal and paste it outside (like select a command and paste it into a mail for ex), here is something that may not be the most efficient way to go, but it works:
echo string | pbcopy
or
echo "complex string" | pbcopy

For ex, to put the above line in the pastebpard, I'd do:
echo "echo \"complex string\" | pbcopy" | pbcopy

Popular, if not outdated, posts...

.docx .NET .pptx .sdf .xlsx AASync accented letters Accessibility Accessibility Inspector Alan Kay alignment Apple AppleScript ApplescriptObjC AppleTrans applications Aquamacs Arabic archive Automator backup bash BBEdit Better Call Saul bug Butler C Calculator Calendar Chinese Cocoa Command line CSV CSVConverter database defaults Devon Dictionary DITA DocBook Dock Doxygen EDICT Emacs emacs lisp ergonomics Excel external disk file formats file system File2XLIFF4j Finder Fink Font français Free software FSF Fun Get A Mac git GNU GPL Guido Van Rossum Heartsome Homebrew HTML IceCat Illustrator InDesign input system ITS iWork Japanese Java Java Properties Viewer Java Web Start json keybindings keyboard Keynote killall launchd LISA lisp locale4j localisation MacPorts Mail markdown MARTIF to TBX Converter Maxprograms Mono MS Office NeoOffice Numbers OASIS Ocelot ODF Okapi OLPC OLT OmegaT OnMyCommand oo2po OOXML Open Solaris OpenDocument OpenOffice.org OpenWordFast org-mode OSX Pages PDF PDFPen PlainCalc PO Preview programming python QA Quick Look QuickSilver QuickTime Player Rainbow RAM reggy regular expressions review rsync RTFCleaner Safari Santa Claus scanner Script Debugger Script Editor scripting scripting additions sdf2txt security Services shell shortcuts Skim sleep Smultron Snow Leopard Spaces Spanish spellchecking Spotlight SRX standards StarOffice Stingray Study SubEthaEdit Swordfish System Events System Preferences TBX TBXMaker Terminal text editing TextEdit TextMate TextWrangler The Tool Kit Time Capsule Time Machine tmutil TMX TMX Editor TMXValidator transifex Translate Toolkit translation Transmug troubleshooting TS TTX TXML UI Browser UI scripting Unix VBA vi Virtaal VirtualBox VLC W3C WebKit WHATWG Windows Wine Word WordFast wordpress writing Xcode XLIFF xml XO xslt YAML ZFS Zip