Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create bash_completion for Octopress rake targets #1728

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions utils/bash_completion/README.markdown
Original file line number Diff line number Diff line change
@@ -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)
13 changes: 13 additions & 0 deletions utils/bash_completion/rake
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions utils/rake_post.sh
Original file line number Diff line number Diff line change
@@ -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