Best BASH Profile

The best BASH profile additions ever. I created a working copy with everything below. You can easily implement the following addons with the following (if you are root):

cd /etc/profile.d
wget lukesnow.net/lukes_addons.sh

With this approach, these addons will be available for all users on the system. If you just want it for your own login, edit the .bashrc, or .profile, and add the following line to it:

source lukes_addons.sh

Probably the best one, in my opinion, is the history search. This makes the command line radically more effective, in that you can search through the history for the last time you issued a command. Suppose you typed "ls really/long/path" last week, and issued many commands since. If you just type "ls " and then press the "up" arrow, it will search the the history to the last "ls" command. If you keep pressing the "up" arrow, it will continue scrolling through the commands. You can also press "down" arrow to go back to the command you just looked at.

# Quickly moving up the directory tree.
alias cd1='cd ../'
alias cd2='cd ../../'
alias cd3='cd ../../../'

# To preserve dates when copying, use archive mode.
alias cp='cp -a'

# See only directories under current, and don't list full contents.
alias lsd='ls -d */'

# Function to change directories by
# replacing one part of name in path.
# e.g. switch from:
# /home/users/joey/really/long/path
# to:
# /home/users/boby/really/long/path
# syntax:
# cdp joey boby
function cdp () {
cd ${PWD/${1}/${2}}
}
# History search...
# Below: autocomplete with the up/down/back/forward keys.
# updates the last run of the partially typed command.
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
bind '"\e0A": history-search-backward'
bind '"\e0B": history-search-forward'
bind '"\e0C": forward-char'
bind '"\e[C": forward-char'
bind '"\e0D": backward-char'
bind '"\e[D": backward-char'
# Set up the prompt so that it displays current directory.
PS1='[\W]: '
# Add current directory to PATH.
PATH=$PATH:./:
# alias
cd='[cd_func](https://github.com/camillobruni/script/blob/master/cd_func.sh "cd_func")'
# follow link for function.  Very useful
# function that adds a history of up to 10 directories visited.
# To see the list directories, use cd --.  To visit, say, the third
# most recent, use cd -3.  Found this one from cygwin.

Comments !