Sunday, September 6, 2009

Linux Bash Commands

1. echo $SHELL -- to know the current shell
2. chsh -s /bin/bash - to change the current shell.
3. echo $SHELLOPTS - Which shell mode is being used (vi or emacs)
4. set -o emacs - to set shell mode to emacs
5. By default bash doesn't check it's window size after every command. The good thing is that you can make it. Add "shopt -s checkwinsize" to your ~/.bashrc or /etc/profile.
echo "shopt -s checkwinsize" >> ~/.bashrc (or /etc/profile)
source ~/.bashrc
try again
6. Problem: rm: cannot chdir from `festival/' to `config': Permission denied
Solution: chmod -R u+rwx * in the directory
7. Yet to come.

Bash Shell Keyboard Shortcuts:
Moving around:
Ctrl-b - Move a character backwards.
Ctrl-f - Move a character forward.
Alt-b - Move cursor backward one word on the current line.
Alt-f - Move cursor forward one word on the current line.
Ctrl-a - Move to the beginning of the current line.
Ctrl-e - Move to the end of the current line.
Ctrl-x-x - to the start, and to the end again

Cut, copy and paste:
Ctrl-d - Delete the character the cursor is on.
Ctrl-h - Delete a character before the cursor.
Ctrl-u - Delete from the cursor back to the line start.
Ctrl-k - Delete from the cursor to the end of the line.
Ctrl-x Backspace - Delete all characters in the line up till the current cursor position.
Alt-d - Delete the word, starting at the current cursor position.
Alt-Backspace - Delete every character from the current cursor position to the first character of a word that is encountered.
Ctrl-w - Delete the word, untill after the previous word boundary.
Ctrl-y - Yank/Paste previous killed text at the cursor position.
Alt-y - Yank/Paste previous previous killed text at the cursor position.

History
Ctrl-p - Move in history to the previous line.
Ctrl-n - Move in history to the next line.
Ctrl-r - Incrementally search the line history, Backwardly.
Ctrl-s - Incrementally search the line history, Forwardly.
Ctrl-J - End an incremental search.
Ctrl-G - Abort an incremental search and restore the original line.
Alt-Ctrl-y - Yank/Paste arg. 1 of prev. cmnd at the cursor position.
Alt-. OR Alt-_ - Yank/Paste last arg of prev. cmnd at the cursor position.

Undo
Ctrl-_ OR Ctrl-x OR Ctrl-u - Undo the last editing command; you can undo all the way back to an empty line.
Alt-r - Undo all changes made to this line.
Ctrl-l - Clear the screen, reprinting the current line at the top

Completion
TAB - Auto-complete a name.
Alt-/ - Auto-complete a name (without smart completion).
Alt-? - List the possible completions of the preceeding text.
Alt-* - Insert all possible completions of the preceeding text.

Transpose
Ctrl-t - Swap (transpose) the characters the cursor is on, and the character before the cursor.
Alt-t - Swap (transpose) the current word with the previous word.

CASE
Alt-u - Make the word uppercase, starting at the current cursor position.
Alt-l - Make the word lowercase, starting at the current cursor position.
Alt-c - Capitalize the current word character or the next word character that is encountered.

Use "set t_ti= t_te=" in .vimrc
if you don't want clear vim output after exit vim.


References:
http://www.slackbasics.org/html/chap-shell.html

http://faq.programmerworld.net/misc/linux-keyboard-shortcuts.html
http://article.gmane.org/gmane.linux.gentoo.user/57011
http://www.linuxquestions.org/questions/linux-general-1/disable-the-clear-after-you-close-vi-657233/#post3221832
http://www.bigsmoke.us/readline/shortcuts

No comments:

Post a Comment