Created
May 19, 2016 12:56
-
-
Save mathieujobin/b8069655fb7b318b2053d94c931b3148 to your computer and use it in GitHub Desktop.
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
$!/bin/bash | |
if [ $# -eq 1 -a -d $1 ] | |
then | |
# argument is a folder, lets find the first file | |
first_file=`find $1 -type f | grep -v "$1/\.git/" | head -n 1` | |
if [ "$first_file" = "" ] | |
then | |
echo "directory contains no files, good bye" | |
exit 1 | |
fi | |
# is the folder within a git repo? | |
(cd $1 ; git status > /dev/null 2>&1) | |
if [ $? -eq 0 ] | |
then | |
echo "$1 is already part of a git repo, opening the first file found in kate" | |
exec kate $first_file | |
else | |
echo "$1 is not part of a git repo, would you like to initialize one? [y/N]" | |
read answer | |
if [ "$answer" = "y" ] | |
then | |
( cd $1 ; git init ; exec kate $first_file ) | |
else | |
echo "alright, have a nice day." | |
fi | |
fi | |
else | |
echo "more than one argument or was not a folder, kate must know how to handle it." | |
exec kate $* | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment