Skip to content

Instantly share code, notes, and snippets.

@jonahbron
Created May 24, 2013 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonahbron/5647006 to your computer and use it in GitHub Desktop.
Save jonahbron/5647006 to your computer and use it in GitHub Desktop.
Compress and archive project directory, with tab completion.
# Compress and archive project directory. Only deletes project directory if compression is successful.
#
# author Jonah Dahlquist
# license CC0
export PROJECTS_PATH=~/Projects
parchive() {
local project=$1
local year=`date +%Y`
mkdir -p $PROJECTS_PATH/.archives/$year
tar -czf $PROJECTS_PATH/.archives/$year/$project.tar.gz -C $PROJECTS_PATH $project/ \
&& rm -rf $PROJECTS_PATH/$project/
}
project_tab_complete() {
local cur opts
cur="${COMP_WORDS[COMP_CWORD]}"
opts=$(cd $PROJECTS_PATH ; ls -d * | sed 's|/./||')
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
}
complete -F project_tab_complete parchive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment