add fileext function to helpers
parent
bf62d67339
commit
e2cade08c7
1
load.sh
1
load.sh
|
@ -82,6 +82,7 @@ for dir in ${1:-$BASH_SHELL_DIRS}; do
|
||||||
[[ "$dir" = "$BASH_SHELL_BASE" ]] && export BASH_SHELL_BASE_LOADED=true
|
[[ "$dir" = "$BASH_SHELL_BASE" ]] && export BASH_SHELL_BASE_LOADED=true
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# env | grep NETWORK
|
||||||
|
|
||||||
# # set one or the other of these in shell.env if you want to load networks with every shell
|
# # set one or the other of these in shell.env if you want to load networks with every shell
|
||||||
if [[ $BASH_SHELL_HOME_NETWORK_LOAD ]] || [[ $BASH_SHELL_ALL_NETWORKS_LOAD ]] || [[ $BASH_SHELL_NETWORKS_LOAD ]] ; then
|
if [[ $BASH_SHELL_HOME_NETWORK_LOAD ]] || [[ $BASH_SHELL_ALL_NETWORKS_LOAD ]] || [[ $BASH_SHELL_NETWORKS_LOAD ]] ; then
|
||||||
|
|
|
@ -21,6 +21,11 @@ filename() {
|
||||||
echo $(basename "$1" | rev | cut -f 2- -d '.' | rev)
|
echo $(basename "$1" | rev | cut -f 2- -d '.' | rev)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fileext() {
|
||||||
|
# passed entire path
|
||||||
|
echo $1 | awk -F . '{print $NF}'
|
||||||
|
}
|
||||||
|
|
||||||
# // TODO remove and use path module
|
# // TODO remove and use path module
|
||||||
# // must change acl.lib and loginout, chromium, and ungoogled install files
|
# // must change acl.lib and loginout, chromium, and ungoogled install files
|
||||||
adirname() {
|
adirname() {
|
||||||
|
|
62
shell.env
62
shell.env
|
@ -1,17 +1,17 @@
|
||||||
#!/bin/bash
|
# !/bin/bash
|
||||||
# UCI SHELL REPOS ENVIRONMENT
|
# UCI SHELL REPOS ENVIRONMENT
|
||||||
# see README.md for details of how the system work
|
# see README.md for details of how the system work
|
||||||
# In a nutshell its a set of directories that are sourced when creating a shell
|
# In a nutshell its a set of directories that are sourced when creating a shell
|
||||||
# The repos allow one to organize functionality across machines, users and networks
|
# The repos allow one to organize functionality across machines, users and networks
|
||||||
|
|
||||||
# In general do not change or edit this base shell.env file
|
# In general do not change or edit this base shell.env file
|
||||||
# Instead add a custom shell.env to specific shell host directory,
|
# Instead add a custom shell.env to specific shell host directory,
|
||||||
# user shell directory or dev shell directory
|
# user shell directory or dev shell directory
|
||||||
|
|
||||||
# echo DEBUG: sourcing shell.env
|
# echo DEBUG: sourcing shell.env
|
||||||
|
|
||||||
# This file gets sourced early in /etc/profile for all login and
|
# This file gets sourced early in /etc/profile for all login and
|
||||||
# for interactive non-login shells via /etc/bash.bashrc
|
# for interactive non-login shells via /etc/bash.bashrc
|
||||||
|
|
||||||
# for interactive login shell (ssh is about the only case)
|
# for interactive login shell (ssh is about the only case)
|
||||||
# loading the shell might cause issues specially using rsync
|
# loading the shell might cause issues specially using rsync
|
||||||
|
@ -21,11 +21,11 @@
|
||||||
|
|
||||||
# if bash is not installed then don't bother to continue
|
# if bash is not installed then don't bother to continue
|
||||||
! command -v bash >/dev/null 2>&1 && echo no bash command && return 1
|
! command -v bash >/dev/null 2>&1 && echo no bash command && return 1
|
||||||
export SHELL=$(command -v bash )
|
export SHELL="$(command -v bash )"
|
||||||
|
|
||||||
# without changing /etc/profile you can disable loading the UCI Shell system
|
# without changing /etc/profile you can disable loading the UCI Shell system
|
||||||
# by uncommenting this line. It will only set up a simple prompt instead.
|
# by uncommenting this line. It will only set up a simple prompt instead.
|
||||||
# if UCI shell is causing issues then one can invoke this
|
# if UCI shell is causing issues then one can invoke this
|
||||||
# BASH_SAFE_MODE=true
|
# BASH_SAFE_MODE=true
|
||||||
# todo add safemode enable/disable function that (un)comments
|
# todo add safemode enable/disable function that (un)comments
|
||||||
|
|
||||||
|
@ -41,13 +41,13 @@ fi
|
||||||
|
|
||||||
# within each of those directories if a load.sh exits it will be run
|
# within each of those directories if a load.sh exits it will be run
|
||||||
# otherwise files will be sourced according to load.sh in the base repo
|
# otherwise files will be sourced according to load.sh in the base repo
|
||||||
export BASH_SHELL_LOAD=$BASH_SHELL_BASE/load.sh # load.sh is default
|
export BASH_SHELL_LOAD="$BASH_SHELL_BASE/load.sh" # load.sh is default"
|
||||||
|
|
||||||
export BASH_SHELL_STARTUP=$BASH_SHELL_BASE/startup.sh # startup.sh is default
|
export BASH_SHELL_STARTUP="$BASH_SHELL_BASE/startup.sh # startup.sh is default"
|
||||||
|
|
||||||
# for non-interactive login shells (like at boot)
|
# for non-interactive login shells (like at boot)
|
||||||
# load this library that allows loading additional modules
|
# load this library that allows loading additional modules
|
||||||
export BASH_ENV=$BASH_SHELL_BASE/module.lib # module loading functions
|
export BASH_ENV="$BASH_SHELL_BASE/module.lib # module loading functions"
|
||||||
# otherwise comment above and uncommented next line
|
# otherwise comment above and uncommented next line
|
||||||
# export BASH_ENV=$BASH_SHELL_LOAD # load same as interactive shell, beware usually causes issues!!!
|
# export BASH_ENV=$BASH_SHELL_LOAD # load same as interactive shell, beware usually causes issues!!!
|
||||||
|
|
||||||
|
@ -57,34 +57,34 @@ export BASH_ENV=$BASH_SHELL_BASE/module.lib # module loading functions
|
||||||
# By default it will set up a master directory /shell
|
# By default it will set up a master directory /shell
|
||||||
|
|
||||||
# DEFAULT DIRECTORY STRUCTURE
|
# DEFAULT DIRECTORY STRUCTURE
|
||||||
# /shell
|
# /shell
|
||||||
# -- base # $BASH_SHELL_BASE=/shell/base (default) is set in /etc/profile during setup
|
# -- base # $BASH_SHELL_BASE=/shell/base (default) is set in /etc/profile during setup
|
||||||
# -- any
|
# -- any
|
||||||
# -- host
|
# -- host
|
||||||
# -- network
|
# -- network
|
||||||
# -- networks
|
# -- networks
|
||||||
# -- <network name>
|
# -- <network name>
|
||||||
# -- <another network name>
|
# -- <another network name>
|
||||||
# -- <hostname>
|
# -- <hostname>
|
||||||
# -- $HOME/shell # user
|
# -- $HOME/shell # user
|
||||||
|
|
||||||
# default loading preference is first in list is lowest and last is highest
|
# default loading preference is first in list is lowest and last is highest
|
||||||
# for example a function "test" in the BASE will be overwritten by one the HOST repo
|
# for example a function "test" in the BASE will be overwritten by one the HOST repo
|
||||||
# that is the same for startup scripts and module loading.
|
# that is the same for startup scripts and module loading.
|
||||||
|
|
||||||
BASH_SHELL_DIRS="$BASH_SHELL_BASE "
|
BASH_SHELL_DIRS="$BASH_SHELL_BASE "
|
||||||
|
|
||||||
declare parent
|
declare parent
|
||||||
parent=$(dirname $BASH_SHELL_BASE)
|
parent="$(dirname $BASH_SHELL_BASE)"
|
||||||
|
|
||||||
# Any Host
|
# Any Host
|
||||||
BASH_SHELL_ANY_HOST=${parent}/any/host # or set to
|
BASH_SHELL_ANY_HOST="${parent}/any/host # or set to"
|
||||||
# export BASH_SHELL_ALL_HOSTS=<some directory>
|
# export BASH_SHELL_ALL_HOSTS=<some directory>
|
||||||
[[ -d $BASH_SHELL_ANY_HOST ]] && BASH_SHELL_DIRS+="$BASH_SHELL_ANY_HOST " && export BASH_SHELL_ANY_HOST
|
[[ -d $BASH_SHELL_ANY_HOST ]] && BASH_SHELL_DIRS+="$BASH_SHELL_ANY_HOST " && export BASH_SHELL_ANY_HOST
|
||||||
|
|
||||||
BASH_SHELL_ANY_NETWORK=$parent/any/network
|
BASH_SHELL_ANY_NETWORK=$parent/any/network
|
||||||
# BASH_SHELL_ALL_NETWORKS=<some directory>
|
# BASH_SHELL_ALL_NETWORKS=<some directory>
|
||||||
[[ -d $BASH_SHELL_ANY_NETWORK ]] && BASH_SHELL_DIRS+="$BASH_SHELL_ANY_NETWORK " && export BASH_SHELL_ANY_NETWORK
|
[[ -d $BASH_SHELL_ANY_NETWORK ]] && BASH_SHELL_DIRS+="$BASH_SHELL_ANY_NETWORK " && export BASH_SHELL_ANY_NETWORK
|
||||||
# these are all the base directories to source
|
# these are all the base directories to source
|
||||||
export BASH_SHELL_DIRS
|
export BASH_SHELL_DIRS
|
||||||
|
|
||||||
|
@ -97,14 +97,14 @@ BASH_SHELL_HOST=$parent/$(hostname)
|
||||||
|
|
||||||
# if this directory exists it is included first in the sourcing
|
# if this directory exists it is included first in the sourcing
|
||||||
# if allows on the develop scripts and modules, etc for later incorporation into a repo
|
# if allows on the develop scripts and modules, etc for later incorporation into a repo
|
||||||
BASH_SHELL_DEV=${BASH_SHELL_DEV:-/opt/shell}
|
BASH_SHELL_DEV=${BASH_SHELL_DEV:-/opt/shell}
|
||||||
[[ -d $BASH_SHELL_DEV ]] && export BASH_SHELL_DEV
|
[[ -d $BASH_SHELL_DEV ]] && export BASH_SHELL_DEV
|
||||||
|
|
||||||
# by default USER shell sources will be looked for under $HOME/shell
|
# by default USER shell sources will be looked for under $HOME/shell
|
||||||
# export BASH_SHELL_USER_DIR=$HOME/shell
|
export BASH_SHELL_USER_DIR=$HOME/shell
|
||||||
|
|
||||||
|
|
||||||
# set up default location to look for other network shell directories
|
# set up default location to look for other network shell directories
|
||||||
BASH_NETWORKS_DIR=$parent/networks
|
BASH_NETWORKS_DIR=$parent/networks
|
||||||
# BASH_NETWORKS_DIR=<some directory> # alt directory to look for networks
|
# BASH_NETWORKS_DIR=<some directory> # alt directory to look for networks
|
||||||
export BASH_NETWORKS_DIR
|
export BASH_NETWORKS_DIR
|
||||||
|
@ -128,16 +128,16 @@ source $BASH_SHELL_BASE/module.lib
|
||||||
# echo $BASH_SHELL_DIRS
|
# echo $BASH_SHELL_DIRS
|
||||||
# echo ---------------------------------
|
# echo ---------------------------------
|
||||||
|
|
||||||
#archived ---for deletion or better explanation
|
# archived ---for deletion or better explanation
|
||||||
# echo enabling aliases with non-interactive shell
|
# echo enabling aliases with non-interactive shell
|
||||||
# DEPRECATED # export BASH_USE_ALIAS=true # will source aliases for non-interactive
|
# DEPRECATED # export BASH_USE_ALIAS=true # will source aliases for non-interactive
|
||||||
# if not using implicit sourcing for non-interactive shells then one can do this per script
|
# if not using implicit sourcing for non-interactive shells then one can do this per script
|
||||||
##################
|
# #################
|
||||||
# expanding aliases is optional
|
# expanding aliases is optional
|
||||||
# shopt -s expand_aliases
|
# shopt -s expand_aliases
|
||||||
# source $BASH_SHELL_LOAD
|
# source $BASH_SHELL_LOAD
|
||||||
# < your script code >
|
# < your script code >
|
||||||
# shopt -u expand_aliases
|
# shopt -u expand_aliases
|
||||||
####################
|
# ###################
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue