First working copy of autoload
This commit is contained in:
parent
f8ff3fe5b9
commit
67e3a383d7
6 changed files with 47 additions and 0 deletions
18
.bashrc
Executable file
18
.bashrc
Executable file
|
@ -0,0 +1,18 @@
|
|||
#
|
||||
# ~/.bashrc
|
||||
#
|
||||
|
||||
# Stripped of its default items
|
||||
|
||||
function autoload {
|
||||
#echo "Called by $(caller): Couldn't find ${BASH_COMMAND}"
|
||||
if [[ -f modules/${BASH_COMMAND}.bash ]]
|
||||
then
|
||||
source modules/${BASH_COMMAND}.bash
|
||||
${BASH_COMMAND}
|
||||
else
|
||||
echo "I can't find ${BASH_COMMAND}"
|
||||
fi
|
||||
}
|
||||
|
||||
trap autoload ERR
|
0
LICENSE
Normal file → Executable file
0
LICENSE
Normal file → Executable file
0
NOTES
Normal file → Executable file
0
NOTES
Normal file → Executable file
0
README.md
Normal file → Executable file
0
README.md
Normal file → Executable file
6
modules/moo.bash
Executable file
6
modules/moo.bash
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
# Test module
|
||||
|
||||
function moo () {
|
||||
echo "MOOOO!! $1"
|
||||
}
|
23
test.bash
Executable file
23
test.bash
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
# 2>/dev/null
|
||||
|
||||
# Test file
|
||||
|
||||
function autoload {
|
||||
#echo "Called by $(caller): Couldn't find ${BASH_COMMAND}"
|
||||
if [[ -f modules/${BASH_COMMAND}.bash ]]
|
||||
then
|
||||
source modules/${BASH_COMMAND}.bash
|
||||
${BASH_COMMAND}
|
||||
else
|
||||
echo "I can't find ${BASH_COMMAND}"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
trap autoload ERR
|
||||
|
||||
moo
|
Loading…
Add table
Add a link
Reference in a new issue