Re: [Nottingham] Bash commands

From: Martin (martin_at_ml1.co.uk)
Date: Fri 06 Feb 2004 - 21:44:23 GMT


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 to
> 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 easy
> to modify it to accept arguments.
>
> alias lsd='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 • 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='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='.:..:../..:~/links:~:~/projects:/var/www/virtual_hosts'
export CDPATH='.:..:../..:~/Documents'

# Bash’s programmable completion enables commands’ 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=1

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

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

alias md="mkdir"
alias rd="rmdir"
alias cp="cp -i" # Interactive overwrites (note danger!)
alias mv="mv -i" # Interactive overwrites (note danger!)
alias rm="rm -i" # Interactive deletes (note danger!)

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

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

-- 
----------------
Martin Lomas
martin_at_ml1.co.uk
----------------

_______________________________________________ Nottingham mailing list Nottingham_at_mailman.lug.org.uk http://mailman.lug.org.uk/mailman/listinfo/nottingham