Simple command line editor with Readline support
# for alternatives see http://codesnippets.joyent.com/posts/show/1625 unset -f edit function edit() { declare -a ar declare -i i=-1 while read -e -d $'\n' line; do let i++; ar[$i]="${line}"; done # -e enables readline printf "%s\n" "${ar[@]}" >> ~/.bash_history #printf "%s\n" "${ar[@]}" | tr '\n' ' ' >> ~/.bash_history #printf "%s\n" >> ~/.bash_history history -n eval "${ar[@]}" return 0 } edit echo "!"; [ctrl-r] [ctrl-d] # quit and execute the command [ctrl-c] # do not execute the command and abort