1#=============================================================================
2#
3# FILE NAME
4#
5# .bash_profile
6#
7# DESCRIPTION
8#
9# Unix startup file executed upon log in. If you want to run this file every
10# time you open a new Terminal window in Linux, you will need to change Gnome
11# settings as follows: go to Terminal->Preferences->Profiles, create a new profile
12# Under Command enable Run command as login shell.
13#
14# See also install documentation for various apps here:
15# http://seanerikoconnor.freeservers.com/WebDesign/macLinuxComputerSetupForDevelopers.html
16#
17# DATE
18#
19# 17 Oct 24
20#
21# AUTHOR
22#
23# Sean E. O'Connor
24#
25#=============================================================================
26#
27
28# When you first set up your macOS system. turn on a bunch of settings, then leave them off.
29#whentoexecute="once"
30whentoexecute=""
31
32#------------- Portability -------
33#
34# Try to determine which system we are running on.
35
36#-----------------------------------------------------------------------------
37#--- Set the path
38#-----------------------------------------------------------------------------
39
40# Be sure to put useful scripts and executables into the home bin directory: ~/bin
41bins="/usr/local/bin:~/bin"
42
43# You need to set the hostname to get the correct configuration loaded.
44# On MacBook,
45# sudo hostname WhiteHusky"
46# sudo scutil --set LocalHostName WhiteHusky
47# sudo scutil --set ComputerName WhiteHusky
48# sudo scutil --set HostName WhiteHusky
49# In System Preferences/Sharing change 'Computer Name' to WhiteHusky if it's not already changed.
50# In your local network configuration, rename the name provided by DHCP.
51# On Ubuntu Linux, to change the hostname permanently,
52# hostnamectl set-hostname Gauss
53
54# Find out the hostname. In cygwin bash, strip off the trailing \r introduced.
55# The alternative is to use tr -d '\r'
56hostname=`python3 -c "import platform; print( platform.node() )" | sed 's/^[ \r\n\t]*$//'`
57#echo "hostname=|${hostname}|"
58
59# Find out which operating system we are running on: macOS, Linux, Windows/Cygwin, etc.
60uname=`uname -s`
61#echo "uname=|${uname}|"
62
63# macOS. Tested on my MacBook Pro laptop mid-2015 model with Intel x86_64 architecture.
64if [ "${uname}" == "Darwin" ] ; then
65 platform="macos"
66# Linux. Tested on my Ubuntu Linux system running on my Cyperpower PC with a 64-bit AMD CPU.
67elif [ "${uname}" == "Linux" ] ; then
68 platform="linux"
69# Cygwin. For cygwin 2.2 64-bit on Windows 10 64-bit. Not tested. From https://en.wikipedia.org/wiki/Uname
70elif [ "${uname}" == "CYGWIN_NT-10.0" ] ; then
71 platform="cygwin"
72else
73 echo "Can't identify OS platform = ${platform}. Exiting .bash_profile"
74 exit 1
75fi
76#echo "Using platform = ${platform}"
77
78if [ "${platform}" == "macos" ] ; then
79 py3bin="/Library/Frameworks/Python.framework/Versions/3.13/bin"
80 #printf "Using macOS System Python version path = ${PATH}\n"
81# Linux. Tested on my Ubuntu Linux system running on my Cyperpower PC with a 64-bit AMD CPU.
82elif [ "${platform}" == "linux" ] ; then
83 py3bin="/usr/local/bin:${HOME}/.local/bin"
84 #printf "Using Ubuntu Linux Python version path = ${PATH}\n"
85elif [ "${platform}" == "cygwin" ] ; then
86 py3bin="/usr/local/bin"
87 #printf "Using Cygwin Linux Python version path = ${PATH}\n"
88fi
89
90if [ "${platform}" == "macos" ] ; then
91 # Not quite the final path -- For macOS, add the path to brew and add export brew's environment variables.
92 # To see help documentation on this, run
93 # /opt/homebrew/bin/brew -h shellenv
94 eval "$(/opt/homebrew/bin/brew shellenv)"
95fi
96
97# CMake tool used for Blender.
98cmakebin="/Applications/CMake.app/Contents/bin/"
99
100# Latest version of make and ack.
101makebin="/usr/local/bin"
102
103# Final path.
104PATH="${HOME}:${makebin}:${cmakebin}:${py3bin}:${bins}:${PATH}"
105#echo "Final path = ${PATH}"
106export PATH
107
108# Python paths for additional private library modules. See
109# https://docs.python.org/3/using/cmdline.html#environment-variables
110# Even inside a virtual environment, pip will search the PYTHONPATH. So you may have clashes between module inside and outside
111# the virtual environment if you aren't careful. Look at the pip module locations using
112# pip list -v
113export PYTHONPATH="${HOME}/Desktop/Sean/Arts/Visual/Painting/OriginalWorks/CGI/Scripts/lib"
114
115# On Ubuntu Linux, run the Python virtual environment.
116if [ "${platform}" == "linux" ] ; then
117 #echo "Linux: set up Python virtual environment for all terminal windows"
118 if [[ -f ~/.VENV/bin/activate ]] ; then
119 source ~/.VENV/bin/activate # This was commented out by conda initialize
120 echo "Entering `python3 -V` virtual environment at ${VIRTUAL_ENV}. Type deactivate to exit."
121 else
122 echo "WARNING: No Python virtual environment on system. Recommend you set one up."
123 fi
124fi
125
126# Make sure Python 3 is installed on your system. Get the version and redirect from stderr to stdout.
127python_version=`python3 -V 2>&1`
128
129# Delete minor versions (numbers after the first dot), and spaces, e.g. Python 3.13 => Python3
130python_version_stripped=`echo ${python_version} | sed 's/\.[0-9]*//g' | sed 's/[ \r]//g'`
131
132#echo "Python version ${python_version} was detected"
133#echo "stripped version = ${python_version_stripped}"
134
135# Check the version and give help.
136if [ "${python_version_stripped}" != "Python3" ] ; then
137 echo "WARNING: Calling o l d python version ${python_version} stripped ${python_version_stripped} from `which python` in path $PATH"
138fi
139
140# Default settings.
141ls_color_option="-G"
142desk_dir="${HOME}/Desktop"
143thumb_dir="/Volumes/ALNILAM"
144extra_bin_path="/usr/local/bin"
145
146#------------- Export base directories for use by other programs -------------
147
148# The root directory has /Sean under it and /Sean/WebSite underneath that.
149export desk_dir
150export thumb_dir
151
152#echo "Root dir |${desk_dir}|, thumb dir |${thumb_dir}|, desk_dir |${desk_dir}|"
153
154#------------- Directory Shorthands -------------
155
156# Top level directories
157sean_dir="${desk_dir}/Sean"
158app_dir="${desk_dir}/App"
159export sean_dir
160export app_dir
161
162# Level 1 directories.
163arts_dir="${sean_dir}/Arts"
164business_dir="${sean_dir}/Business"
165family_dir="${sean_dir}/Family"
166science_dir="${sean_dir}/Sciences"
167web_dir="${sean_dir}/WebSite"
168export arts_dir
169export business_dir
170export family_dir
171export science_dir
172export web_dir
173
174# Quickly cd to subdirectories by typing cd subdir.
175# Need . in the list to avoid having to put ./ in front of directories.
176export CDPATH=.:~:${sean_dir}:${pp_src_dir}
177
178# Mac system tweaks.
179if [ "${platform}" == "macos" ] ; then
180 if [ "${whentoexecute}" == "once" ] ; then
181 # Show hidden files in finder (needs a relaunch of finder).
182 defaults write com.apple.finder AppleShowAllFiles TRUE && killall Finder
183
184 # Remove the Auto-Hide Dock Delay
185 defaults write com.apple.Dock autohide-delay -float 0 && killall Dock
186
187 # Speed Up Mission Control Animations
188 defaults write com.apple.dock expose-animation-duration -float 0.12 && killall Dock
189
190 # Make Hidden App Icons Translucent in the Dock
191 defaults write com.apple.Dock showhidden -bool YES && killall Dock
192
193 # Change Screen Shots image type from PNG to JPG
194 defaults write com.apple.screencapture type jpg && killall SystemUIServer
195 fi
196
197 # XCode location.
198 # Some apps like opendiff, launched from git difftool will need to know this.
199 export DEVELOPER_DIR=/Applications/Xcode.app
200fi
201
202# Finish up the aliases.
203source .bashrc
204
205# Setting PATH for Python 3.13
206# The original version is saved in .bash_profile.pysave
207PATH="/Library/Frameworks/Python.framework/Versions/3.13/bin:${PATH}"
208export PATH