These are mainly from this thread:
gt5 -- cli gui for du
autojump -- jumping to most used dirs
iptraf -- network monitor
Vengeance Is Mine, I Shall Repay
Files can be opened from the command line as if they were double clicked.
open command.kde-open and gnome-open respectively.I have created a function in my .bashrc, so that I can open files by the command o. Just add it to ~/.bashrc and source .bashrc or reboot(!)
function o
{
kde-open "$@" &>/dev/null &
}
This sends all stdout and stderr to outer space in order to save you an Enter press, so beware.
Bonus: Actually, all this was done so that I can open the files in dired mode in emacs by their default application, pdf, jpg, mp3 files etc.
(define-key dired-mode-map "o" 'dired-launch-command)
(defun dired-launch-command ()
(interactive)
(dired-do-shell-command
(case system-type
(gnu/linux "kde-open") ;right for gnome (ubuntu), not for other systems
(darwin "open"))
nil
(dired-get-marked-files t current-prefix-arg)))
Now in dired mode, pressing 'o' will open the file in the default application.
See here if that doesn't work.
MATLAB shell has a sometimes useful variable called ans which you can use in your current calculations as a variable. My TI-83 had one as well actually, but Bash doesn't have one. :)
So, suppose you want to make use of the latest Bash command output. Using !! will redo the previous command. Using !! inside backticks (` `) or $( ) will give its output, as any other Bash command. (Although the $ notation is preferred, the backtick is more convenient in this particular case.)
So, operating on the last output is as simple as:
command_name `!!`
Note that this redoes the previous action, doesn't actually make use of the latest output.
One example:
$ which firefox
/usr/bin/firefox
#This is usually the symlink, we want to learn where the actual target is.
$ ls -l `!!`
Another one:
$ find -name "*.org"
$ emacs `!!`
Note that the -exec option of find or feeding to xargs might be more suitable in most cases, but this is just for demonstration.
Of course, C-p C-a command_name ` C-e ` is an option, but this seems easier.
Inspired via: http://feedproxy.google.com/~r/Command-line-fu/~3/mvkfpS8SZfw/edit-list-of-files-in-last-command
Via readline, some of Emacs' keybindings are available on the command line.
I was aware some shortcuts like C-a, C-e, C-r were already working; but was surprised to discover that even more are available, like undo, capitalize word etc.
Via:
http://www.catonmat.net/blog/bash-emacs-editing-mode-cheat-sheet/ and from "man readline"
"C-@" set-mark
"C-A" beginning-of-line
"C-B" backward-char
"C-D" delete-char
"C-E" end-of-line
"C-F" forward-char
"C-G" abort
"C-H" backward-delete-char
"C-I" complete
"C-J" accept-line
"C-K" kill-line
"C-L" clear-screen
"C-M" accept-line
"C-N" next-history
"C-P" previous-history
"C-Q" quoted-insert
"C-R" reverse-search-history
"C-S" forward-search-history
"C-T" transpose-chars
"C-U" unix-line-discard
"C-V" quoted-insert
"C-W" unix-word-rubout
"C-Y" yank
"C-]" character-search
"C-_" undo
" " to "/" self-insert
"0" to "9" self-insert
":" to "~" self-insert
"C-?" backward-delete-char
Emacs Meta bindings
"M-C-G" abort
"M-C-H" backward-kill-word
"M-C-I" tab-insert
"M-C-J" vi-editing-mode
"M-C-M" vi-editing-mode
"M-C-R" revert-line
"M-C-Y" yank-nth-arg
"M-C-[" complete
"M-C-]" character-search-backward
"M-space" set-mark
"M-#" insert-comment
"M-&" tilde-expand
"M-*" insert-completions
"M--" digit-argument
"M-." yank-last-arg
"M-0" digit-argument
"M-1" digit-argument
"M-2" digit-argument
"M-3" digit-argument
"M-4" digit-argument
"M-5" digit-argument
"M-6" digit-argument
"M-7" digit-argument
"M-8" digit-argument
"M-9" digit-argument
"M-<" beginning-of-history "M-=" possible-completions "M->" end-of-history
"M-?" possible-completions
"M-B" backward-word
"M-C" capitalize-word
"M-D" kill-word
"M-F" forward-word
"M-L" downcase-word
"M-N" non-incremental-forward-search-history
"M-P" non-incremental-reverse-search-history
"M-R" revert-line
"M-T" transpose-words
"M-U" upcase-word
"M-Y" yank-pop
"M-\" delete-horizontal-space
"M-~" tilde-expand
"M-C-?" backward-kill-word
"M-_" yank-last-arg
Emacs Control-X bindings
"C-XC-G" abort
"C-XC-R" re-read-init-file
"C-XC-U" undo
"C-XC-X" exchange-point-and-mark
"C-X(" start-kbd-macro
"C-X)" end-kbd-macro
"C-XE" call-last-kbd-macro
"C-XC-?" backward-kill-line
PS: C-/ also works for undo. Note that C-w is not the same as the Emacs default.
PPS: This is my current .inputrc, mostly the same as /etc/inputrc, except the last 8 lines.
# /etc/inputrc - global inputrc for libreadline
# See readline(3readline) and `info rluserman' for more information.
# Be 8 bit clean.
set input-meta on
set output-meta on
# To allow the use of 8bit-characters like the german umlauts, comment out
# the line below. However this makes the meta key not work as a meta key,
# which is annoying to those which don't need to type in 8-bit characters.
# set convert-meta off
# try to enable the application keypad when it is called. Some systems
# need this to enable the arrow keys.
# set enable-keypad on
# see /usr/share/doc/bash/inputrc.arrows for other codes of arrow keys
# do not bell on tab-completion
# set bell-style none
# set bell-style visible
# some defaults / modifications for the emacs mode
$if mode=emacs
# allow the use of the Home/End keys
"\e[1~": beginning-of-line
"\e[4~": end-of-line
# allow the use of the Delete/Insert keys
"\e[3~": delete-char
"\e[2~": quoted-insert
# mappings for "page up" and "page down" to step to the beginning/end
# of the history
# "\e[5~": beginning-of-history
# "\e[6~": end-of-history
# alternate mappings for "page up" and "page down" to search the history
# "\e[5~": history-search-backward
# "\e[6~": history-search-forward
# mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
"\e[1;5C": forward-word
"\e[1;5D": backward-word
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word
$if term=rxvt
"\e[8~": end-of-line
"\eOc": forward-word
"\eOd": backward-word
$endif
# for non RH/Debian xterm, can't hurt for RH/Debian xterm
# "\eOH": beginning-of-line
# "\eOF": end-of-line
# for freebsd console
# "\e[H": beginning-of-line
# "\e[F": end-of-line
$endif
"\e[A": history-search-backward
"\e[B": history-search-forward
"\M-o": "\C-p\C-a\M-f "
set match-hidden-files off
set completion-ignore-case on
set visible-stats on
set show-all-if-ambiguous on
"\M-s": menu-complete
cd: blt: No such file or directory
Once inside the symlink, issuing cd .. to go to the parent dir doesn't work. It returns to the dir where the symlink resides.
To go to the parent dir of the actual dir where symlink points to, use "cd -P .."
du -sm * | sort -rg
Calculates the disk usage in MB's and sorts in reverse order.
"\eo": "\C-p\C-a\ef "
"\e[A": history-search-backward
"\e[B": history-search-forward
set completion-ignore-case on
set show-all-if-ambiguous on
"\es": menu-complete
alias ..='cd ..'
alias home='cd ~'
alias mat='cd ~/Documents/Matlab'
alias doc='cd ~/Documents/'
alias ping='ping -c 10'
alias ls='ls -G'
alias qlf='qlmanage -p'
export DISPLAY=localhost:0.0
shopt -s histappend
PROMPT_COMMAND='history -a'
shopt -s cdspell
test -r /sw/bin/init.sh && . /sw/bin/init.sh
if [ "$TERM" != 'dumb' ] && [ -n "$BASH" ] && [ -n "$PS1" ]
then
if [ `/usr/bin/whoami` = 'root' ]
then
export PS1='[\[\033[01;31m\]\h \[\033[01;34m\]\W \$ \[\033[00m\]'
else
export PS1='\[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]'
fi
fi
alias matlab2='matlab -nodesktop -nosplash'
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
export HISTCONTROL=ignoreboth