diff --git a/utils/bash_completion/README.markdown b/utils/bash_completion/README.markdown new file mode 100644 index 00000000000..ec6f7e9792b --- /dev/null +++ b/utils/bash_completion/README.markdown @@ -0,0 +1,35 @@ +# octopress_bash_completion +This will auto complete targets for used in [Octopress](http://octopress.org/) + +--- +# Install +* copy rake to /etc/bash_completion.d/ +* relogin or `. /etc/bash_completion.d/rake` + +# Auto complete targets +* deploy +* generate +* preview +* watch +* new_post +* new_page +* isolate +* integrate +* clean +* update_style +* update_source +* gen_deploy +* copydot +* rsync +* set_root_dir +* setup_github_pages +* list +* -T +* install + +# Tested environment +* Ubuntu 14.04 + +# Reference +* [An introduction to bash completion: part 1](http://www.debian-administration.org/article/316/An_introduction_to_bash_completion_part_1) +* [An introduction to bash completion: part 2](http://www.debian-administration.org/article/317/An_introduction_to_bash_completion_part_2) diff --git a/utils/bash_completion/rake b/utils/bash_completion/rake new file mode 100644 index 00000000000..1e02f455d2c --- /dev/null +++ b/utils/bash_completion/rake @@ -0,0 +1,13 @@ +_rake() +{ + local current_keyin_str targets + COMPREPLY=() + current_keyin_str="${COMP_WORDS[COMP_CWORD]}" + targets="deploy generate preview watch new_post new_page isolate \ + integrate clean update_style update_source gen_deploy \ + copydot rsync set_root_dir setup_github_pages list -T \ + install" + + COMPREPLY=( $(compgen -W "${targets}" -- ${current_keyin_str}) ) +} +complete -F _rake rake diff --git a/utils/rake_post.sh b/utils/rake_post.sh new file mode 100755 index 00000000000..e42031173f5 --- /dev/null +++ b/utils/rake_post.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# Check parameter +if [ "$#" = "0" ] ; then + echo "usage: $(basename $0) [octopress markdown flie]" + exit +fi + +# Check file +if [ ! -f "$1" ] ; then + echo "No such file: $1" + exit +fi + +# Let's create and process markdown +SCRIPT_FILE="/tmp/run_rake.sh" + +cat << EOF_ > $SCRIPT_FILE +#!/bin/bash +rake isolate['$1'] +rake generate +rake preview +rake integrate +rake generate +EOF_ + +chmod +x $SCRIPT_FILE +bash -x $SCRIPT_FILE