This is my idea of what a scripter's bashrc should look like!

Hello! :slight_smile:

I thought I’d share this one, that way I save a lot more time! :smiley:
It is to be used from your $HOME directory, and Not from the Console, or from /etc
I use bash version 4.2.29 you should get away with doing minor changes should you use something older, but I’d recommend walking through every option then.

Enjoy!

[code]#!/bin/bash

************* set -v -x

************* Debug

export DISPLAY=:0.0
export IFS=’
'# The Terminal.app is set up with xterm-color, and to export the LC_LANG stuff (Language/Locale )
TZ=CET
export TZ
export TERMINFO=$TERM

export TMOUT=90000

25 hours in seconds before timeout

*********** SAFETY ************************

ulimit -S -c 0

Provides control over the resources available to the shell and

to processes started by it, on systems that allow such control.

-S option specify that the soft limit is set

for the given resource. A soft limit may be increased up to

the value of the hard limit. (Automatic )

-c The maximum size of core files created (0)

*************** SET - OPTIONS **************************

set -a

Automatically mark variables and functions which are

modified or created for export to the environment of

subsequent commands. (shopt allexport)

set -b

Report the status of terminated background jobs immedi-

ately, rather than before the next primary prompt. This

is effective only when job control is enabled.

set -e

Exit immediately if a simple command (see SHELL GRAMMAR

above) exits with a non-zero status. The shell does not

exit if the command that fails is part of the command

list immediately following a while or until keyword,

part of the test in an if statement, part of a && or ||

list, or if the command’s return value is being inverted

via !. A trap on ERR, if set, is executed before the

shell exits.

set -f

Disable pathname expansion.

set -h

Remember the location of commands as they are looked up

for execution. This is enabled by default.

set -k

All arguments in the form of assignment statements are

placed in the environment for a command, not just those

that precede the command name. (!! declare -x stmnts !!)

set -m

Monitor mode. Job control is enabled. This option is

on by default for interactive shells on systems that

support it (see JOB CONTROL above). Background pro-

cesses run in a separate process group and a line con-

taining their exit status is printed upon their comple-

tion.

set -n

Read commands but do not execute them. This may be used

to check a shell script for syntax errors. This is

ignored by interactive shells.

*************** SET -o OPTIONS **************************

allexport

Same as -a. (Above)

set -o braceexpand

Same as -B. (Below)

set -o emacs

Use an emacs-style command line editing inter-

face. This is enabled by default when the shell

is interactive, unless the shell is started with

the --noediting option.

set -o errtrace

Same as -E. (Below)

set -o functrace

Same as -T. (Above)

set -o errexit

Same as -e. (Above)

set -o hashall

Same as -h. (Above)

set -o histexpand

Same as -H. (Below)

set -o history

Enable command history, as described above under HISTORY.

This option is on by default in interactive shells.

keyword

Same as -k. (Above)

set -o monitor

Same as -m (Above)

set -o noclobber

Same as -C. (Below)

set -o noexec

Same as -n. (Above)

set -o noglob

Same as -f. (Above)

set -o

nolog Currently ignored.

set -o notify

Same as -b. (Above)

set -o nounset

Same as -u. (Below)

set -o onecmd

Same as -t. (Below)

set -o physical

Same as -P. (Below)

set -o pipefail

If set, the return value of a pipeline is the

value of the last (rightmost) command to exit

with a non-zero status, or zero if all commands

in the pipeline exit successfully. This option

is disabled by default.

set -o posix

Change the behavior of bash where the default

operation differs from the POSIX standard to

match the standard (posix mode)

set -o privileged

Same as -p. (Below)

set -o verbose

Same as -v. (Below)

set -o vi

Use a vi-style command line editing interface.

set -o xtrace

Same as -x. (Below)

*************** SET - OPTIONS **************************

set -p

Turn on privileged mode. In this mode, the $ENV and

$BASH_ENV files are not processed, shell functions are

not inherited from the environment, and the SHELLOPTS

variable, if it appears in the environment, is ignored.

If the shell is started with the effective user (group)

id not equal to the real user (group) id, and the -p

option is not supplied, these actions are taken and the

effective user id is set to the real user id. If the -p

option is supplied at startup, the effective user id is

not reset. Turning this option off causes the effective

user and group ids to be set to the real user and group

ids.

set -t

Exit after reading and executing one command.

set -u

Treat unset variables as an error when performing param-

eter expansion. If expansion is attempted on an unset

variable, the shell prints an error message, and, if not

set -v

Print shell input lines as they are read.

set -x

After expanding each simple command, for command, case

command, select command, or arithmetic for command, dis-

play the expanded value of PS4, followed by the command

and its expanded arguments or associated word list.

set -B

The shell performs brace expansion (see Brace Expansion

above). This is on by default.

set -C

If set, bash does not overwrite an existing file with

the >, >&, and <> redirection operators. This may be

overridden when creating output files by using the redi-

rection operator >| instead of >.

set -E

If set, any trap on ERR is inherited by shell functions,

command substitutions, and commands executed in a sub-

shell environment. The ERR trap is normally not inher-

ited in such cases.

set -H

Enable ! style history substitution. This option is on

by default when the shell is interactive.

set -P

If set, the shell does not follow symbolic links when

executing commands such as cd that change the current

working directory. It uses the physical directory

structure instead. By default, bash follows the logical

chain of directories when performing commands which

change the current directory.

set -T

If set, any traps on DEBUG and RETURN are inherited by

shell functions, command substitutions, and commands

executed in a subshell environment. The DEBUG and

RETURN traps are normally not inherited in such cases.

set –

If no arguments follow this option, then the positional

parameters are unset. Otherwise, the positional parame-

ters are set to the args, even if some of them begin

with a -.

set -

Signal the end of options, cause all remaining args to

be assigned to the positional parameters. The -x and -v

options are turned off. If there are no args, the posi-

tional parameters remain unchanged.

The options are off by default unless otherwise noted. Using +

rather than - causes these options to be turned off. The

options can also be specified as arguments to an invocation of

the shell. The current set of options may be found in $-. The

return status is always true unless an invalid option is encoun-

tered.

************* SHOPTIONS ***************************

shopt -s cdable_vars

If set, an argument to the cd builtin command that is

not a directory is assumed to be the name of a variable

whose value is the directory to change to.

shopt -s cdspell

If set, minor errors in the spelling of a directory com-

ponent in a cd command will be corrected. The errors

checked for are transposed characters, a missing charac-

ter, and one character too many. If a correction is

found, the corrected file name is printed, and the com-

mand proceeds. This option is only used by interactive

shells.

shopt -s checkhash

If set, bash checks that a command found in the hash ta-

ble exists before trying to execute it. If a hashed

command no longer exists, a normal path search is per-

formed.

shopt -s checkwinsize

If set, bash checks the window size after each command

and, if necessary, updates the values of LINES and COL-

UMNS.

shopt -s cmdhist

If set, bash attempts to save all lines of a multiple-

line command in the same history entry. This allows

easy re-editing of multi-line commands.

shopt -s compat31

If set, bash changes its behavior to that of version 3.1

with respect to quoted arguments to the conditional com-

mand’s =~ operator.

shopt -s dotglob

If set, bash includes filenames beginning with a `.’ in

the results of pathname expansion.

There was something between this setting and noclobber in 2.05b

shopt -u execfail

If set, a non-interactive shell will not exit if it can-

not execute the file specified as an argument to the

exec builtin command. An interactive shell does not

exit if exec fails.

shopt -s expand_aliases

If set, aliases are expanded as described above under

ALIASES. This option is enabled by default for interac-

tive shells.

shopt -s extdebug

If set, behavior intended for use by debuggers is

enabled:

1. The -F option to the declare builtin displays the

source file name and line number corresponding to

each function name supplied as an argument.

2. If the command run by the DEBUG trap returns a

non-zero value, the next command is skipped and

not executed.

3. If the command run by the DEBUG trap returns a

value of 2, and the shell is executing in a sub-

routine (a shell function or a shell script exe-

cuted by the . or source builtins), a call to

return is simulated.

4. BASH_ARGC and BASH_ARGV are updated as described

in their descriptions above.

5. Function tracing is enabled: command substitu-

tion, shell functions, and subshells invoked with

( command ) inherit the DEBUG and RETURN traps.

6. Error tracing is enabled: command substitution,

shell functions, and subshells invoked with (

command ) inherit the ERROR trap.

shopt -s extglob

If set, the extended pattern matching features described

above under Pathname Expansion are enabled.

shopt -s extquote

If set, $‘string’ and $“string” quoting is performed

within ${parameter} expansions enclosed in double

quotes. This option is enabled by default.

shopt -s failglob

If set, patterns which fail to match filenames during

pathname expansion result in an expansion error.

shopt -s force_fignore

If set, the suffixes specified by the FIGNORE shell

variable cause words to be ignored when performing word

completion even if the ignored words are the only possi-

ble completions. See SHELL VARIABLES above for a

description of FIGNORE. This option is enabled by

default.

shopt -s gnu_errfmt

If set, shell error messages are written in the standard

GNU error message format.

shopt -s histappend

If set, the history list is appended to the file named

by the value of the HISTFILE variable when the shell

exits, rather than overwriting the file.

shopt -s histreedit

If set, and readline is being used, a user is given the

opportunity to re-edit a failed history substitution.

shopt -s histverify

If set, and readline is being used, the results of his-

tory substitution are not immediately passed to the

shell parser. Instead, the resulting line is loaded

into the readline editing buffer, allowing further modi-

fication.

shopt -s hostcomplete

If set, and readline is being used, bash will attempt to

perform hostname completion when a word containing a @

is being completed (see Completing under READLINE

above). This is enabled by default.

shopt -s huponexit

If set, bash will send SIGHUP to all jobs when an inter-

active login shell exits.

shopt -s interactive_comments

If set, allow a word beginning with # to cause that word

and all remaining characters on that line to be ignored

in an interactive shell (see COMMENTS above). This

option is enabled by default.

shopt -u lithist

If set, and the cmdhist option is enabled, multi-line

commands are saved to the history with embedded newlines

rather than using semicolon separators where possible.

login_shell

The shell sets this option if it is started as a login

shell (see INVOCATION above). The value may not be

changed.

shopt -u mailwarn

If set, and a file that bash is checking for mail has

been accessed since the last time it was checked, the

message ``The mail in mailfile has been read’’ is dis-

played.

shopt -u no_empty_cmd_completion

If set, and readline is being used, bash will not

attempt to search the PATH for possible completions when

completion is attempted on an empty line.

shopt -u nocaseglob

If set, bash matches filenames in a case-insensitive

fashion when performing pathname expansion (see Pathname

Expansion above).

shopt -u nocasematch

If set, bash matches patterns in a case-insensitive

fashion when performing matching while executing case or

[[ conditional commands.

shopt -s nullglob

If set, bash allows patterns which match no files (see

Pathname Expansion above) to expand to a null string,

rather than themselves.

shopt -s progcomp

If set, the programmable completion facilities (see Pro-

grammable Completion above) are enabled. This option is

enabled by default.

shopt -s promptvars

If set, prompt strings undergo parameter expansion, com-

mand substitution, arithmetic expansion, and quote

removal after being expanded as described in PROMPTING

above. This option is enabled by default.

restricted_shell

The shell sets this option if it is started in

restricted mode (see RESTRICTED SHELL below). The value

may not be changed. This is not reset when the startup

files are executed, allowing the startup files to dis-

cover whether or not a shell is restricted.

shopt -s shift_verbose

If set, the shift builtin prints an error message when

the shift count exceeds the number of positional parame-

ters.

shopt -s sourcepath

If set, the source (.) builtin uses the value of PATH to

find the directory containing the file supplied as an

argument. This option is enabled by default.

shopt -s xpg_echo

If set, the echo builtin expands backslash-escape

sequences by default.

************ HISTORY SYSTEM ****************************

the $HISTCMD variable contains nr of last event.

HISTCONTROL=ignoredups
HISTFILE=~/.bash_history
HISTFILESIZE=2000
HISTSIZE=2000
HISTIGNORE=!:/:^:ls:‘ls -l’:‘man bash’:exit:‘cd…’

HISTTIMEFORMAT="%a%c " # VER. 3.0 and later.

export HISTFILESIZE HISTSIZE HISTCONTROL HISTIGNORE HISTTIMEFORMAT

alias hi=“history |less”

export FCEDIT="nano -k "

history command line editor invoked with ‘fc’

*******************************************************

export HIST_STARTNUM=wc -l <~/.bash_history

I Recommend you add your project directories after the Documents directories

the CDPATH makes you move quickly!

~/Documents/* ~/Library/* ~/Library/Scripts/* ~/Library/Scripts/Applications/* ~/Library/Application\ Support/* ~/Library/* /Library/Scripts/* ~/Library/Application\ Support/* /opt/local/* /opt/local/share/* /usr/local/* /usr/local/share/* /Developer/* /Developer/usr/* /Developer/usr/share/* /*

CDPATH=“.:…:~:~/Desktop:~/Documents:~/Documents/Prj:~/bin:/usr/local:/usr/local/share:/opt/local”

for realm in ~/* ~/Desktop/* ~/Documents/* ~/Library/* ~/Library/Scripts/* ~/Library/Scripts/Applications/* ~/Library/Application\ Support/* ~/Library/* /Library/Scripts/* ~/Library/Application\ Support/* /opt/local/* /opt/local/share/* /usr/local/* /usr/local/share/* /Developer/* /Developer/usr/* /Developer/usr/share/* /*
do
for folder in $realm
do
if [ -d ${folder} ]
then
CDPATH=“$CDPATH”:“$folder”
fi
done
done

export CDPATH

shopt -s nullglob must be set for succesful use of this construct.

export PATH=$HOME/bin:/opt/local/bin:/opt/local/sbin:$PATH:$MYSQLBIN

Path initially set up in in .MacOsx/Environment.plist

export EDITOR=/usr/bin/bbedit

your editor here…

export PAGER=/usr/bin/less
export LESS=“-I -R -f -J -S -g -M -x 4”

-a All hits current page

-I Ignore case ;

-r “raw” doesn’t escape ctrl-chars,

-R Raw, but shows ansi escape sequences

-F Don’t open file if less than screen ful

-f force open special files (may be binary)

-J show status column

-S chop long lines.

-g highlight only last match

-M Most Verbose …

export LESSOPEN=‘| /opt/local/bin/lesspipe.sh %s’

export MANPAGER=/usr/bin/less

export CLICOLOR=1 #enables commandline colors
export LSCOLORS=bxGxcxdxbxegedabagacad

Not perfectly happy with those, but no time for it now.

I have “iron” background

alias more=/usr/bin/less

*****************************************************************************[/code]