diff options
author | An-Cheng Huang <ancheng@vyatta.com> | 2007-11-12 13:06:02 -0800 |
---|---|---|
committer | An-Cheng Huang <ancheng@vyatta.com> | 2007-11-12 13:06:02 -0800 |
commit | b7fc9e0f6d6105ba2203f219743d4b269415e84b (patch) | |
tree | ef6586dfc62798c2b17487b443864699aca55f31 /examples/startup-files | |
download | vyatta-bash-b7fc9e0f6d6105ba2203f219743d4b269415e84b.tar.gz vyatta-bash-b7fc9e0f6d6105ba2203f219743d4b269415e84b.zip |
initial import from bash_3.1dfsg.orig.tar.gz
Diffstat (limited to 'examples/startup-files')
-rw-r--r-- | examples/startup-files/Bash_aliases | 63 | ||||
-rw-r--r-- | examples/startup-files/Bash_profile | 18 | ||||
-rw-r--r-- | examples/startup-files/Bashrc.bfox | 70 | ||||
-rw-r--r-- | examples/startup-files/README | 5 | ||||
-rw-r--r-- | examples/startup-files/apple/README | 24 | ||||
-rw-r--r-- | examples/startup-files/apple/aliases | 34 | ||||
-rw-r--r-- | examples/startup-files/apple/bash.defaults | 22 | ||||
-rw-r--r-- | examples/startup-files/apple/environment | 24 | ||||
-rw-r--r-- | examples/startup-files/apple/login | 15 | ||||
-rw-r--r-- | examples/startup-files/apple/logout | 10 | ||||
-rw-r--r-- | examples/startup-files/apple/rc | 63 | ||||
-rw-r--r-- | examples/startup-files/bash-profile | 39 | ||||
-rw-r--r-- | examples/startup-files/bashrc | 132 |
13 files changed, 519 insertions, 0 deletions
diff --git a/examples/startup-files/Bash_aliases b/examples/startup-files/Bash_aliases new file mode 100644 index 0000000..bb9c01e --- /dev/null +++ b/examples/startup-files/Bash_aliases @@ -0,0 +1,63 @@ +# Some useful aliases. +alias texclean='rm -f *.toc *.aux *.log *.cp *.fn *.tp *.vr *.pg *.ky' +alias clean='echo -n "Really clean this directory?"; + read yorn; + if test "$yorn" = "y"; then + rm -f \#* *~ .*~ *.bak .*.bak *.tmp .*.tmp core a.out; + echo "Cleaned."; + else + echo "Not cleaned."; + fi' +alias h='history' +alias j="jobs -l" +alias l="ls -l " +alias ll="ls -l" +alias ls="ls -F" +alias pu="pushd" +alias po="popd" + +# +# Csh compatability: +# +alias unsetenv=unset +function setenv () { + export $1="$2" +} + +# Function which adds an alias to the current shell and to +# the ~/.bash_aliases file. +add-alias () +{ + local name=$1 value="$2" + echo alias $name=\'$value\' >>~/.bash_aliases + eval alias $name=\'$value\' + alias $name +} + +# "repeat" command. Like: +# +# repeat 10 echo foo +repeat () +{ + local count="$1" i; + shift; + for i in $(seq 1 "$count"); + do + eval "$@"; + done +} + +# Subfunction needed by `repeat'. +seq () +{ + local lower upper output; + lower=$1 upper=$2; + + if [ $lower -ge $upper ]; then return; fi + while [ $lower -le $upper ]; + do + echo -n "$lower " + lower=$(($lower + 1)) + done + echo "$lower" +} diff --git a/examples/startup-files/Bash_profile b/examples/startup-files/Bash_profile new file mode 100644 index 0000000..141e8df --- /dev/null +++ b/examples/startup-files/Bash_profile @@ -0,0 +1,18 @@ +# Startup file for bash login shells. +# +default_dir=/usr/local/lib/ + +if [ -n "$PS1" ]; then + PS1='\u@\h(\#)\$ ' + IGNOREEOF=3 +fi + +LOGIN_SHELL=true + +# If the user has her own init file, then use that one, else use the +# canonical one. +if [ -f ~/.bashrc ]; then + . ~/.bashrc +elif [ -f ${default_dir}Bashrc ]; then + . ${default_dir}Bashrc; +fi diff --git a/examples/startup-files/Bashrc.bfox b/examples/startup-files/Bashrc.bfox new file mode 100644 index 0000000..efe7d88 --- /dev/null +++ b/examples/startup-files/Bashrc.bfox @@ -0,0 +1,70 @@ +# Bourne Again SHell init file. +# +# Files you make look like rw-rw-r +umask 002 + +# Don't make useless coredump files. If you want a coredump, +# say "ulimit -c unlimited" and then cause a segmentation fault. +ulimit -c 0 + +# Sometimes, there are lots of places that one can find tex inputs. +export TEXINPUTS=.:$HOME/bin:/usr/lib/tex/inputs:/usr/local/lib/tex/inputs + +# Where's the Gnu stuff at? +GNU=/usr/gnu/bin +X11=/usr/bin/X11 + +UTIL_PATH=$GNU:$X11 +STANDARD_PATH=/usr/local/bin:/usr/ucb:/bin:/usr/bin:/usr/etc:/etc:/usr/games + +if [ -d $HOME/bin/$HOSTTYPE ]; then + MY_PATH=$HOME/bin/$HOSTTYPE +fi + +if [ -d $HOME/bin ]; then + MY_PATH=$MY_PATH:$HOME/bin +fi + +if [ -d /usr/hosts ]; then + STANDARD_PATH=$STANDARD_PATH:/usr/hosts +fi + +PATH=.:$MY_PATH:$UTIL_PATH:$STANDARD_PATH + +# If not running interactively, then return +if [ -z "$PS1" ]; then + return +fi + +# Set ignoreeof if you don't want EOF as the sole input to the shell to +# immediately signal a quit condition. This only happens at the start +# of a line if the line is empty, and you haven't just deleted a character +# with C-d. I turn this on in ~/.bash_profile so that only login shells +# have the right to be obnoxious. +# set -o ignoreeof + +# Set auto_resume if you want to resume on "emacs", as well as on +# "%emacs". +auto_resume=exact + +# Set notify if you want to be asynchronously notified about background +# job completion. +set -o notify + +# Make it so that failed `exec' commands don't flush this shell. +shopt -s execfail + +if [ -z "$LOGIN_SHELL" ]; then + PS1="\u@\h\$ " +fi + +HISTSIZE=256 +MAILCHECK=60 + +# A couple of default aliases. +alias j='jobs -l' +alias po=popd +alias pu=pushd +alias ls='ls -F' + +[ -f ~/.bash_aliases ] && . ~/.bash_aliases diff --git a/examples/startup-files/README b/examples/startup-files/README new file mode 100644 index 0000000..bdbfd90 --- /dev/null +++ b/examples/startup-files/README @@ -0,0 +1,5 @@ +Some sample startup files. The ones starting with capital letters +are originally from Brian Fox. The ones starting with lowercase +letters are from Chet Ramey. + +They will require changes for your environment. diff --git a/examples/startup-files/apple/README b/examples/startup-files/apple/README new file mode 100644 index 0000000..07005cb --- /dev/null +++ b/examples/startup-files/apple/README @@ -0,0 +1,24 @@ +This directory contains some useful bash files. + +In order to use this configuration: + + echo "source ~/.bashrc" > ~/.profile + echo "source /usr/share/init/bash/rc" > ~/.bashrc + echo "source /usr/share/init/bash/login" > ~/.login + +In order to customize this setup: + + mkdir ~/Library/init/bash + +and create the following files there as necessary: + + aliases.mine - shell aliases + completions.mine - completions + environment.mine - environment + rc.mine - run commands + path - command search path + +See the corresponding file in /usr/share/init/bash for more information about the role of each file. You can easily extend or override the configuration provided by the default file. For example, you can add more aliases by adding the appropriate commands in aliases.mine. + + -Fred + tritan@mit.edu diff --git a/examples/startup-files/apple/aliases b/examples/startup-files/apple/aliases new file mode 100644 index 0000000..23d3399 --- /dev/null +++ b/examples/startup-files/apple/aliases @@ -0,0 +1,34 @@ +## +# Bash aliases file +# +# Wilfredo Sanchez Jr. | tritan@mit.edu +## + +## +# Aliases +## + +alias .='cwd' +alias ..='cd ..' +alias cd..='cd ..' +alias cdwd='cd $(/bin/pwd)' +alias cwd='echo $PWD' +alias l='ls -lg' + +## +# Functions +## + +files () { find ${1} -type f -print ; } +ff () { find . -name ${1} -print ; } +ll () { ls -lag "$@" | more ; } +word () { fgrep -i "$*" /usr/dict/web2 ; } +wordcount () { cat "${1}" | tr -s ' .,;:?\!()[]"' '\012' | \ + awk 'END {print NR}' ; } + +## +# Read user's aliases +## +if [ -r ${bash_initdir}/aliases.mine ]; then + source ${bash_initdir}/aliases.mine +fi diff --git a/examples/startup-files/apple/bash.defaults b/examples/startup-files/apple/bash.defaults new file mode 100644 index 0000000..a80145b --- /dev/null +++ b/examples/startup-files/apple/bash.defaults @@ -0,0 +1,22 @@ +## +# Bash +# User preferences file +# Override these in rc.mine +# +# Wilfredo Sanchez Jr. | tritan@mit.edu +# July 09, 1992 +# +# MIT Project Athena +## + +if [ -n "$PS1" ]; then + + # Prompts + PS1='[\h:\w] \u\$ ' + PS2=' -> ' + #PS3= + #PS4= + + set -o emacs + +fi diff --git a/examples/startup-files/apple/environment b/examples/startup-files/apple/environment new file mode 100644 index 0000000..fee218b --- /dev/null +++ b/examples/startup-files/apple/environment @@ -0,0 +1,24 @@ +## +# Bourne Again Shell environment file +# Global environment setup +# +# Wilfredo Sanchez Jr. | tritan@mit.edu +# July 09, 1992 +# +# MIT Project Athena +# +# ORIGINAL SOURCES: /usr/athena/lib/init/cshrc (ATHENA REL 7.3P) +## + +export ENV_SET="YES" # avoid repeat + +# File creation mask +umask 022 # all files created are -rw-r--r-- + +## +# Load user environment +## + +if [ -f ${bash_initdir}/environment.mine ]; then + source ${bash_initdir}/environment.mine +fi diff --git a/examples/startup-files/apple/login b/examples/startup-files/apple/login new file mode 100644 index 0000000..b91f787 --- /dev/null +++ b/examples/startup-files/apple/login @@ -0,0 +1,15 @@ +## +# Set path +## + +export PATH="${HOME}/${MACHTYPE}/bin:${HOME}/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" + +export MANPATH="${HOME}/man:/usr/local/share/man:/usr/share/man" + +## +# Read user's login +## + +if (-r ${bash_initdir}/login.mine) then + source ${bash_initdir}/login.mine +fi diff --git a/examples/startup-files/apple/logout b/examples/startup-files/apple/logout new file mode 100644 index 0000000..812731c --- /dev/null +++ b/examples/startup-files/apple/logout @@ -0,0 +1,10 @@ +## +# Destroy credentials +## + +if [ -z "${TERM_PROGRAM}" ]; then + # Don't run these commands if the shell is launched by Terminal, + # even if it's a login shell. + + if klist -s; then kdestroy; fi +fi diff --git a/examples/startup-files/apple/rc b/examples/startup-files/apple/rc new file mode 100644 index 0000000..2451b9f --- /dev/null +++ b/examples/startup-files/apple/rc @@ -0,0 +1,63 @@ +## +# Bourne Again Shell config file +# +# Wilfredo Sanchez Jr. | tritan@mit.edu +# July 09, 1992 +# +# MIT Project Athena +# +# ORIGINAL SOURCES: /usr/athena/lib/init/cshrc (ATHENA REL 7.3P) +## + + default_initdir=/usr/share/init +default_bash_initdir=${default_initdir}/bash + user_initdir=~/Library/init + user_bash_initdir=${user_initdir}/bash + +if [ -r ${user_bash_initdir} ]; then + initdir=${user_initdir} + bash_initdir=${user_bash_initdir} +else + initdir=${default_initdir} + bash_initdir=${default_bash_initdir} +fi + +# SET UP HOST-DEPENDANT VARIABLES, ETC. + +host=$(echo $(hostname) | tr A-Z a-z) + +user=`whoami` + +export HOST=${host} +export USER=${user} + +# User ID +if [ -z "${uid}" ]; then uid=$(id | cut -d = -f 2 | cut -d \( -f 1); fi + +# SET COMMAND SEARCH PATH AND MAN PATH +if [ -f ${bash_initdir}/path ]; then source ${bash_initdir}/path; fi + +# ENVIRONMENT SETUP + +if [ -n "${PS1}" ]; then interactive="YES"; fi + +if [ -z "${ENV_SET}" ]; then + if [ -f ${default_bash_initdir}/environment ]; then + #echo "Initializing environment..." + source ${default_bash_initdir}/environment + fi +fi + +if [ -r ${default_bash_initdir}/bash.defaults ]; then + source ${default_bash_initdir}/bash.defaults +fi + +# DEFAULT LOGIN SOURCES +if [ -f ${bash_initdir}/rc.mine ]; then source ${bash_initdir}/rc.mine; fi + +if [ "${interactive}" = "YES" ]; then + # These aren't useful for non-interactive sessions + if [ -f ${default_bash_initdir}/aliases ]; then + source ${default_bash_initdir}/aliases + fi +fi diff --git a/examples/startup-files/bash-profile b/examples/startup-files/bash-profile new file mode 100644 index 0000000..e811df8 --- /dev/null +++ b/examples/startup-files/bash-profile @@ -0,0 +1,39 @@ +# This is the filename where your incoming mail arrives. +MAIL=~/mbox +MAILCHECK=30 + +HISTFILE=~/.history/history.$HOSTNAME + +PATH1=/usr/homes/chet/bin.$HOSTTYPE:/usr/local/bin/gnu: +PATH2=/usr/local/bin:/usr/ucb:/bin:/usr/bin/X11:. +PATH3=/usr/bin:/usr/new/bin:/usr/contrib/bin +PATH=$PATH1:$PATH2:$PATH3 + +EDITOR=/usr/local/bin/ce VISUAL=/usr/local/bin/ce FCEDIT=/usr/local/bin/ce + +SHELL=${SHELL:-${BASH:-/bin/bash}} + +PAGER=/usr/local/bin/less +LESS='-i -e -M -P%t?f%f :stdin .?pb%pb\%:?lbLine %lb:?bbByte %bb:-...' +# +# Bogus 1003.2 variables. This should really be in /etc/profile +# +LOGNAME=${USER-$(whoami)} +TZ=US/Eastern + +export HOME VISUAL EDITOR MAIL SHELL PATH TERM +export PAGER LESS TERMCAP HISTSIZE HISTFILE MAIL MAILCHECK LOGNAME TZ + +PS1="${HOSTNAME}\$ " +PS2='> ' +export PS1 PS2 + +umask 022 + +if [ -f /unix ] ; then + stty intr ^c # bogus +fi + +if [ -f ~/.bashrc ] ; then + . ~/.bashrc +fi diff --git a/examples/startup-files/bashrc b/examples/startup-files/bashrc new file mode 100644 index 0000000..069e8be --- /dev/null +++ b/examples/startup-files/bashrc @@ -0,0 +1,132 @@ +if [ -z "$PS1" ]; then + return +fi + +# bogus +if [ -f /unix ] ; then + alias ls='/bin/ls -CF' +else + alias ls='/bin/ls -F' +fi +alias ll='ls -l' +alias dir='ls -ba' + +alias ss="ps -aux" +alias dot='ls .[a-zA-Z0-9_]*' +alias news="xterm -g 80x45 -e trn -e -S1 -N &" + +alias c="clear" +alias m="more" +alias j="jobs" + +# common misspellings +alias mroe=more +alias pdw=pwd + +hash -p /usr/bin/mail mail + +if [ -z "$HOST" ] ; then + export HOST=${HOSTNAME} +fi + +HISTIGNORE="[ ]*:&:bg:fg" + +psgrep() +{ + ps -aux | grep $1 | grep -v grep +} + +# +# This is a little like `zap' from Kernighan and Pike +# + +pskill() +{ + local pid + + pid=$(ps -ax | grep $1 | grep -v grep | awk '{ print $1 }') + echo -n "killing $1 (process $pid)..." + kill -9 $pid + echo "slaughtered." +} + +term() +{ + TERM=$1 + export TERM + tset +} + +xtitle () +{ + echo -n -e "\033]0;$*\007" +} + +cd() +{ + builtin cd "$@" && xtitle $HOST: $PWD +} + +bold() +{ + tput smso +} + +unbold() +{ + tput rmso +} + +if [ -f /unix ] ; then +clear() +{ + tput clear +} +fi + +rot13() +{ + if [ $# = 0 ] ; then + tr "[a-m][n-z][A-M][N-Z]" "[n-z][a-m][N-Z][A-M]" + else + tr "[a-m][n-z][A-M][N-Z]" "[n-z][a-m][N-Z][A-M]" < $1 + fi +} + +watch() +{ + if [ $# -ne 1 ] ; then + tail -f nohup.out + else + tail -f $1 + fi +} + +# +# Remote login passing all 8 bits (so meta key will work) +# +rl() +{ + rlogin $* -8 +} + +function setenv() +{ + if [ $# -ne 2 ] ; then + echo "setenv: Too few arguments" + else + export $1="$2" + fi +} + +function chmog() +{ + if [ $# -ne 4 ] ; then + echo "usage: chmog mode owner group file" + return 1 + else + chmod $1 $4 + chown $2 $4 + chgrp $3 $4 + fi +} |