Created
March 6, 2015 05:56
-
-
Save merces/36ce6e9602c163cf129e to your computer and use it in GitHub Desktop.
A minimalist shell skeleton
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "bemvindo ao minibash | |
comandos disponiveis: listar sair" | |
while :; do | |
read -p '$ ' cmd | |
case $cmd in | |
listar) | |
ls ;; | |
sair) | |
exit ;; | |
'') | |
continue ;; | |
*) | |
echo $cmd: comando invalido ;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rapaz,
Podia jurar que poderia mandar um pull request aqui "mas não", acho que um tab com autocomplet seria perfeito nessa solução, ajuda a lembrar dos comandos.. ;)
!/bin/bash
declare -a comandos
comandos=('listar'\
'sair')
echo "bemvindo ao minibash
use TAB para ver comandos disponiveis"
set -o vi
bind 'TAB:dynamic-complete-history'
history -s "${comandos[@]}"
while :; do
read -e -p '$ ' cmd
case $cmd in
listar)
ls ;;
sair)
exit ;;
'')
continue ;;
*)
echo $cmd: comando invalido ;;
esac
done