Simple code manager

Posted on Updated on

Sometime, whe need to code on a machine which has no internet access, no SVN/Git installed or configured, and whe would-like not to loose our local modifications…

Here is a simple bash script which save all changed file, in background :

#!/bin/bash
[[ $# == 1  ]] && $0 $1 &&  exit 0

save=~/SAVE    # destination : Save directory
cd /home/regis/Applications/sources/ # Origne 


# Execution: src-directory src-filename dst-filename(relative)
if  [ $# -ge 3 ]; then
  [ ! -d ${save}/$1 ] && mkdir -p ${save}/$1
  [ -f $2 ] && cp $2 ${save}/$3
  exit 0
fi

####### Main: file detection and action

pkill -f "inotifywait.*timefmt.*%T_.*sdfdfsgfghh"
inotifywait -mr --timefmt %Y-%d-%m_%H-%M-%S \
   --format "%w %w%f %w%T_%f sdfdfsgfghh" -e close_write  . |\
    xargs -i /home/regis/nsavec {}

Then run this script in background, with nohup.

Leave a comment