Profile
Table of Contents
1 profile Introduction
These general-purpose components of the user profile are maintained here:
- $HOME/.bash_profile
- $HOME/.user_profile
Since the bash shell prefers the .bash_profile, this
method starts there and uses an existing ~.user_profile
.
This latter is not a default profile to the shell,
but the name seems to be a reasonable place to store user customization.
A user adopting this method would only have to copy their profile
to the .user profile:
cp .profile .user_profile
and install the /.bash_profile
. The profile_init function invokes
an existing .user_profile
1.1 A user has two other alternatives:
- keep the .profile
If you are using a
.profile
now, i.e. neither a .bash_profile nor a .bash_login, then just copy those two from here, and you need no other changes, since the .bash_profile used here will source your existing .profile - edit the .bash_profile
If you are using the
.bash_profile
then append the fragment here to your existing .bash_profile and edit to suit your needs. All your customization then should move to.user_profile
.
1.2 rationale
I've done this now (6/10/18) to factor the login requirements to my shell function practice requires as I take the practice to the public. A companion motive comes from my using the tangle feature in emacs OrgMode.
In this way, I hope to expose the tangled files to the file system in a way that does not rely on an emacs editor to share in a git file-sharing medium.
2 Profile sourcing requirements.
2.1 source_existing
the simplest addition to the user's preferred login profile will allow the user to direct the source-order of additional shell library functions. this is source_existing
2.2 adjusting PATH
supporting the Shell Library Function Standard.
- the next addition adds a user-supplied PATH definition.
- execution directories names conclude in a
/bin
- shell function libraries names conclude in
lib
- functions are added to find functions home libraries
- subsequent PATH additions may be added to support the last requirement. the constitution may be amended.
2.3 general purpose library
A function library of function families with a set of utilities to support this standard is added. Existing functionality includes:
- assertion verification on entering a function
- a format for shell function documentation
- function call tracing
- an object-method model where functions are named {object}_{sub}, with some standard subs: init, help, doc, hint, list, and some object_particular subs; allowing objects to be extended,
2.4 specialized libraries
A means of adding a number of specialized, broad, but-not universally useful libraries. examples are:
- a command lib, command-line only functions
- a application-binding function library: the means to collect functions from various libraries to a single, complete function library which only makes reference to its own functions and the system utilities
- a simple backup/versioning feature
- supporting the emacs OrgMode tangle facility
3 Bash Profile
These files are installed in their respective HOME "dot" locations.
3.1 bash_profile
So, by default, this profile .bash_profile
is the default bash
start-up file. By virtue of the OrgMode tangle directive, it's
installed in its run-time location.
home () { : ~ set or fetch the name of the portable File System; : intended for DROPBOX, but lets use a portable idea.; case $# in 0) : ${ALTHOME:-$HOME};; *) [[ -d $1 ]] && ALTHOME=$1;; esac echo ${ALTHOME:-$HOME} } user_init () { : user_init may be reused after login to repoint : home ${1:-$HOME/Dropbox}; : : ${SYSTEM_SUPPLIED_PATH:=$PATH}; PATH=/usr/local/bin:$SYSTEM_SUPPLIED_PATH PATH=$(home)/bin:$PATH [[ -f ~/.user_profile ]] && source ~/.user_profile } user_init 1>&2 2> ~/.user.err grep ': command' ~/.user.err | sort -u # Setting PATH for Python 3.6, moved to .user_profile # The original version is saved in .bash_profile.pysave # PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}" export PATH
3.2 user profile
Here is the user customizations:
init_init () { init_pathlibs; init_prefs; } init_functions () { set | awk 'NF == 2 && $2 ~ /\(\)/ { print $1 }'; } init_which () { for lib in $*; do which $lib; done ; } init_help () { ${*:-echo} init_{init,libs,which,help}; } init_logadd () { . $1; } init_path () { echo $PATH | tr ':' '\n' | awk ' !pr[$1]++ { printf "%s%s", co, $1; co=":" } ' } init_pathlibs () { PATH=$(home)/bin/ar:$PATH PATH=$(home)/rdb/bin:$PATH PATH=.:./bin:../bin:$HOME/bin:$PATH : : ------------------------------------------------- source the libs -- # init_functions > ~/lib/init_post.txt for lib in $(init_which $(init_libs)); do init_logadd $lib done : ----------------------------------- run, evalutate initialization -- for init in $( set | awk '$1 ~ /_init$/ && $2 ~ /\(\)/ { print $1 }' $* ) do : -------------------------------- except for {user,init}_init -- case $init in user_init | init_init ) continue;; * ) eval $init ;; esac done } init_pypath () { : ---------------------------- model for any large system component -- [[ -d $1 ]] || return : : ${PREPY_PATH:=$PATH} : PATH="$1:${PREPY_PATH}" unset init_pypath } init_prefs () { : ------------------------------------ users particular preferences -- setenv PS1 '\W.$ '; setenv EDITOR emacs; : ------------------------------------ if the user has an .alias.rc -- [[ -f ~/.alias.rc ]] && source ~/.alias.rc : : ---------------------------------------------- and a copy of /RDB -- PATH=$(home)/rdb/bin:$PATH : : --------------- original version is saved in .bash_profile.pysave -- init_pypath /Library/Frameworks/Python.framework/Versions/3.6/bin : : ----------------------------- after all PATH adjustments are made -- PATH=$(init_path); export PATH init_help unset init_prefs } init_libs () { : ------------------- load these libraries found on the users PATH -- : ---------------------------------- e.g. init_which .. init_libs -- ${*:-echo} {mk,nprof,shelf,pub,app,program,cmd,backup,rdbcmd,rd,rdb,fun}lib } init_init 1>&2
3.3 test code block
ls -lrt ../../../bin