A minimal "terminal-app" with maximum comfort for me, you and all of our bash-scripting friends =)
This terminal application skeleton is meant for replacing endless switch-case instructions in your control-scripts. Why reinventing the wheel again and again.
It is minimal because it only depends on standard bash.
It has maximal comfort because:
- easyly add a commands by creating bash scripts in a certain folder
- automatic usage generation (greps command-scripts for specific markers)
- use logging and colored outputs in your scripts
- write tests for your scripts and run with travis or similar
- easy customizing (ca. 300 lines of structured bash code)
- download this repo and extract or run
git clone https://github.com/creative-workflow/easy-terminal-app.git
- ensure all files are executable
chmod +x ./lib/* ./app ./app.bootstrap
Usage: ./app [command] [help|*] Available commands: du show diskusage help print help logs show app logs test run tests Configuration: * edit `./bootstrap` for public configurations * create your private `./app.bootstrap.local` file to store sensitive data (make sure you add app.bootstrap.local to your `.gitignore` file ;) Available libs: color helps dealing with colors in terminal command helps dispatching commands in scripts/commands/* log helps writing and reading app logs os helps detecting current os (exports $is_osx, $is_win, $is_linux) test helper for running tests
Add new command
Create a new file in the folder
ls and add the following lines:
#!/bin/bash #command-info: show directory listening of . ls .
This adds a new command named
ls which simply prints the directory listening of current directory.
Make sure your new commands is executable by running
chmod +x ./lin/commands/*.
And now your new command will be listed under help, run
use logging in your scripts
log_info "log entry"displays green text in the terminal
log_debug "log entry"displays orange text in the terminal
log_error "log entry"displays red text in the terminal
enable log to file
- all log_* calls can also be logged to file (
- enable this by opening the file
./app logs tailto tail the latest log file
- you can also pass params to tail:
./app logs tail -n100
- there is also
./app logs headand
./app logs catavailable
- to see the log command help run
./app logs help
Tests are located under
./lib/test/*. You can execute all tests by running
add a tests
Just duplicate the file
./lib/test/test_help_command and write your own test.
Make sure your new test is executable by running
chmod +x ./lib/test/*.
how tests work
A test file executes some commands and it's exit code will be used to determine if a test was successfull or not. Exit code 0 (
exit 0) means no errors and any other exit code (1-254) indicates that the test failed.
- add advanced command creation guide
- extend testing capabilities by adding assert functions to
- prefix lib function variables with
__, less clashes
- hide commands that start with
- add helper for file handling in
- use absolut path every where, so recursion will be no problem
- add some helpers for git in
- add some helpers for ssh and scp in
- run all commands when testing
- source 'bootstrap.local' if present and add to gitingore
- disable log to file per default
- dont create log folder if log to file is disabled
- dont show lib info when printing help
- auto load all files in lib folder
- initial release