reduardo7 / bashx Goto Github PK
View Code? Open in Web Editor NEWBashX, Extended Bash Shell, a Bash Framework and helper.
License: GNU General Public License v3.0
BashX, Extended Bash Shell, a Bash Framework and helper.
License: GNU General Public License v3.0
Implement hook: "on-error"
Generate global variable for Script-TMP-Dir, where store all temporary files, and cleanup on exit/end.
Function to get backtrace.
Script to generate initial project files and structure.
Output to err out
Example: https://unix.stackexchange.com/a/291867/22180
Here is basic guide.
Lets have an example of script called admin.sh
to which you would like to have autocomplete working.
#!/usr/bin/bash
while [ $# -gt 0 ]; do
arg=$1
case $arg in
option_1)
# do_option_1
;;
option_2)
# do_option_1
;;
shortlist)
echo option_1 option_2 shortlist
;;
*)
echo Wrong option
;;
esac
shift
done
Note option shortlist
. Calling script with this option will print out all possible options for this script.
And here you have the autocomplete.sh
script:
#!/usr/bin/bash
_script() {
_script_commands=$(/path/to/your/admin.sh shortlist)
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=( $(compgen -W "${_script_commands}" -- ${cur}) )
return 0
}
complete -o nospace -F _script /path/to/your/admin.sh
Note that the last argument to complete is the name of the script you want to add autocompletion to. All you need to do is to add your autocomplete script to ~/.bashrc
or /etc/bash_completion.d
as:
source /full-path/to/your/autocomplete.sh
# or
. /full-path/to/your/autocomplete.sh
Finally, make them executable:
chmod a+x admin.sh autocomplete.sh
Installer like curl -s "https://bashx.webpage/v3/install.sh" | bash
Remove @
symbol from files but keep in code.
Implement hook: "on-invalid-action"
Implement service scripts as "utils".
Change >&2
by exec 3>&1
+ >&3
Implement tests
See file, function and line number: http://stackoverflow.com/a/10707498/717267
Documentation about:
Implement @assertWarning
to show warnings on tests.
Use this implementation in "@timeout" when code is not executed (this test is not executed in OSX)
Create a function:
mktemp
, create the file. Throw error on fail.@on-exit
event to delete the temp file (See #4 )A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.