Posted By

s1w on 11/06/14


Tagged

list project path Bash Choice git Projects


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

claudioeden


GIT Bash: projects choice list


 / Published in: Bash
 

URL: http://siwego.net/dev/git.png

  • edit ppath in code header to your git projects path, put this code into .bashrc file and copy it into your $HOME dir (in Win Vista / 7 it is often c:\Users\$YOU)

  • you may want set this file as executable inside GIT bash chmod +x .bashrc (but its probably redundant, since this file is stored on ntfs filesystem)

  1. #!/bin/bash
  2. ppath="/d/-projects/-github"
  3. cd $ppath
  4. unset PROJECTS
  5. PROJECTS+=(".")
  6. i=0
  7.  
  8. echo
  9. echo -e "projects:\n-------------"
  10.  
  11. for f in *
  12. do
  13. if [ -d "$f" ]
  14. then
  15. PROJECTS+=("$f")
  16. echo -e $((++i)) "- \e[1m$f\e[0m"
  17. fi
  18. done
  19.  
  20.  
  21. if [ ${#PROJECTS[@]} -gt 1 ]
  22. then
  23. echo -ne "\nchoose project: "
  24. read proj
  25. case "$proj" in
  26. [0-`expr ${#PROJECTS[@]} - 1`]) cd "${PROJECTS[proj]}" ;;
  27. *) echo " wrong choice" ;;
  28. esac
  29. else
  30. echo "there is no projects"
  31. fi
  32. unset PROJECTS

Report this snippet  

You need to login to post a comment.