LumberjackUser.bash 757 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. # Get full user name of current user
  3. # E.g. "Robbie Hanson"
  4. full1=$(osascript -e "tell application \"System Events\"" -e "get the full name of the current user" -e "end tell")
  5. #echo $full1
  6. # Convert to lower case
  7. # E.g. "robbie hanson"
  8. full2=$(echo $full1 | awk '{print tolower($0)}')
  9. #echo $full2
  10. # Replace spaces with underscores
  11. # E.g. "robbie_hanson"
  12. full3=$(echo ${full2// /_})
  13. #echo $full3
  14. # Remove any characters that are illegal in a macro name
  15. full4=$(echo $full3 | sed 's/[^0-9a-zA-Z_]*//g')
  16. #echo $full4
  17. # If blank, set the name to an anonymous user
  18. if [ "$full4" == "" ]
  19. then
  20. full4='anonymous_user'
  21. fi
  22. echo "// This file is automatically generated" > ${SCRIPT_OUTPUT_FILE_0}
  23. echo "#define $full4 1" >> ${SCRIPT_OUTPUT_FILE_0}