[Nottingham] Bash commands

Martin martin at ml1.co.uk
Sat Feb 7 02:38:49 GMT 2004


Folks,

Despite the last moment venue confusion, I think all worked well.

Greatest apologies for anyone that may have tried breaking into the =

wrong place!... We'll yet get sharper with the admin stuff...

As promised in the talk:

 > Is there any chance the link for the
> talk could make it onto the list for all to see?

See:
http://www.ukuug.org/events/linux2003/papers/bash_tips/index.html

It also helpfully includes side notes that expand on the slides.


> I promised that I'd send the solution to one bash problem which seems t=
o =

> be quite commonplace. The problem is that your command line doesn't =

> overflow to the next line properly and will overwrite what you have =

> already typed. This is caused by resizing the bash window without it =

> realising.
> =

> The solution is very easy, just add the following line to the =

> appropriate place - .bashrc or wherever is best for your distribution. =

> Personally I have it in /etc/profile (on Gentoo) so that it is default =

> for every user.
> =

> The line:
> =

> shopt -s checkwinsize
> =

> Another of my favourite aliases is "lsd", which I define to get a list =

> of directories within the current directory. It does only work for the =

> current directory, so lsd /etc wouldn't work, but it would be quite eas=
y =

> to modify it to accept arguments.
> =

> alias lsd=3D'ls -l | grep ^d'

I'll let the brave experiment with the above.

The even braver can play with this below:

$cat /etc/profile.d/mlbashtips.sh

#
# M Lomas 'bash Hints and Tips'
# 2004/02/04 mlcode ATno ml1s cop uka zzm
#
# Summary of Simon Myers presentation at:
#
# UKUUG Linux 2003 Conference =95 August 2003
# http://www.ukuug.org/events/linux2003/
#
#

# Make Bash append rather than overwrite the history on disk
shopt -s histappend

# Whenever displaying the prompt, write the previous line to disk
PROMPT_COMMAND=3D'history -a'

# Define ls function providing default option
# (Commented out unless you really want this.)
#function ls
#{
#  command ls -F "$@"
#}
#export -f ls

# New function example - duff, a variation of diff
# - Leaves the original name alone for programs relying on it
function duff
{
   diff -ur "$@"
}
export -f duff

# Further useful new functions:

# Long format ls
#function ll
#{
#  command ls -Flh "$@"
#}
#export -f ll

# Pushd and list the docs for a package
function doc
{
   pushd "/usr/share/doc/$1" && ls
}
export -f doc

# Shortcut for using fig2ps
#function fig2ps
#{
#  fig2dev -L ps "$1" "${1%.fig}.ps"
#}
#export -f fig2ps

# Saves [forgetting] having to type the & every time
#function gimp
#{
#  command gimp "$@" &
#}
#export -f gimp


# Bash will cope with each component of the typed path
# having one missing character, one extra character,
# or a pair of characters transposed:
shopt -s cdspell

# set the cd search path
#export CDPATH=3D'.:..:../..:~/links:~:~/projects:/var/www/virtual_hosts'=

export CDPATH=3D'.:..:../..:~/Documents'

# Bash=92s programmable completion enables commands=92 arguments
# to be completed intelligently for different commands
#source /etc/bash_completion

# To disable autocomplete for a particular command, eg: "cd"
#complete -r cd

# Specify that ctl-d must be pressed twice to exit a shell:
# Avoid unwanted exit due to over-twitchy fingers!
#export IGNOREEOF=3D1


# Note:
#
# Downside of such luxuries is that that sometimes
# you have to use systems where they aren=92t configured
#

# M Lomas short aliases list:
alias d=3D"ls"
alias l=3D"ls"                    # classical listing
alias ll=3D"ls -l"                # List detailed
alias la=3D'ls -a'                # List all
alias lsd=3D"ls -d */"            # List only the directory
alias cd..=3D"cd .."              # Catch the missing space
alias s=3D"cd .."                 # 'super' or 'shift to' (parent) dir
alias p=3D"cd -"                  # Previous dir

alias md=3D"mkdir"
alias rd=3D"rmdir"
alias cp=3D"cp -i"                # Interactive overwrites (note danger!)=

alias mv=3D"mv -i"                # Interactive overwrites (note danger!)=

alias rm=3D"rm -i"                # Interactive deletes (note danger!)

alias m=3Dmore                    # Or should this be less?...
alias lla=3D'ls -la'              # List detailed including '.' files
alias llh=3D'ls -lh'              # List detailed with Human numbers
alias ld=3D"ls -d */"             # List only the directory
alias dfh=3D'df -h'               # List fs with Human numbers
alias v=3D'vim'                   # Or should this be vi?...
alias hh=3D'history'              # List the history

#
# Any additions?
#
# Enjoy, Martin.
#




-- =

----------------
Martin Lomas
martin at ml1.co.uk
----------------




More information about the Nottingham mailing list