Created
May 24, 2013 22:47
-
-
Save jonahbron/5647006 to your computer and use it in GitHub Desktop.
Compress and archive project directory, with tab completion.
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
# 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