-######################################################################
-# Track uncommited files (I presume this is very ugly from a real git
-# user perspective)
-
-function git-fm () {
- CURRENT_DIR=$(pwd)
- NB_SUBDIR=0
-
- for i in $(find -name ".git"); do
- NB_SUBDIR=$((NB_SUBDIR+1))
- cd ${CURRENT_DIR}/$(dirname $i)
- NB_MODIFIED=$(git status | grep modified | wc -l)
- if [[ ${NB_MODIFIED} -gt 0 ]]; then
- echo "$(dirname $i) (${NB_MODIFIED})"
- git status | grep modified \
- | sed -e "s/^#\t/ /" | sed -e "s/modified: *//"
- fi
- done
-
- cd ${CURRENT_DIR}
-
- echo "Visited ${NB_SUBDIR} directories."
-}
-
-######################################################################
-# Commits all directories under git
-
-function git-ca () {
- ORIGINAL_PWD=${PWD}
- UNCOMMITTED=""
- for d in $(find ${PWD} -name ".git" | sed -e "s/\.git$//"); do
- cd $d
- NB_MODIFIED=$(git status | grep modified | wc -l)
- if [[ ${NB_MODIFIED} -gt 0 ]]; then
- if [[ $(pwd) =~ ${NO_AUTOMATIC_GIT_COMMIT} ]]; then
- UNCOMMITTED="${UNCOMMITTED} $(pwd)"
- else
- echo $(pwd)" (${NB_MODIFIED} modified file(s))"
- git commit -a -m "Automatic commit" | grep -v ^#
- fi
- # git gc
- fi
- done
-
- cd ${ORIGINAL_PWD}
-
- if [[ ${UNCOMMITTED} ]]; then
- echo "** WARNING: Did not automatically commit${UNCOMMITTED}"
- fi
-}
-
-######################################################################
-# Backups all git directories into an encrypted backup file located
-# either on the usb key or the SD card (in that order) if they can be
-# mounted.
-
-function git-backup () {
-
- BACKUPDIR=/mnt/key
-
- mount ${BACKUPDIR} 2> /dev/null
-
- if [[ ! $(mount | grep ${BACKUPDIR}) ]]; then
- BACKUPDIR=/mnt/sd
- mount ${BACKUPDIR}
- fi
-
- if [[ $(mount | grep ${BACKUPDIR}) ]]; then
- echo "Mounted ${BACKUPDIR}"
- else
- echo "Could not mount the backup directory"
- return 1
- fi
-
- RESULT=${BACKUPDIR}/gitbackup-$(date +%F-%H%M%S).tgz.mc
-
- tar zcvf - $(find ${HOME}/ -name .git) \
- | mcrypt -f ${HOME}/private/mcrypt.key > ${RESULT}
-
- if [[ -f ${RESULT} ]]; then
- ls -lh ${RESULT}
- else
- echo "Could not create the backup!"
- return 1
- fi
-
- sync
-
- umount ${BACKUPDIR} && echo "Umounted ${BACKUPDIR}"
-}
-
-######################################################################
-# Downloads torrents located in ${BT_DIR}/torrents/ and puts the
-# result in the ${BT_DIR}
-
-function bt () {
- if [[ ${BT_DIR} ]]; then
- if [[ -d "${BT_DIR}/torrents" ]]; then
- if [[ $1 ]]; then
- mv $1 ${BT_DIR}/torrents
- fi
- if [[ "$(ps auxwww | grep btlaunchmanycurses | grep -v grep)" ]]; then
- echo "A client is already running."
- else
- cd ${BT_DIR} && screen btlaunchmanycurses torrents --max_upload_rate 32
- fi
- else
- echo "Directory ${BT_DIR}/torrents does not exist."
- fi
- else
- echo "You have to set \$BT_DIR."
- fi
-}
-