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# 09 Jun 24
20#
21# AUTHOR
22#
23# Sean E. O'Connor
24#
25#=============================================================================
26#
27
28#------------- Portability -------
29#
30# Try to determine which system we are running on.
31
32#-----------------------------------------------------------------------------
33#--- Set the path
34#-----------------------------------------------------------------------------
35
36# Be sure to put useful scripts and executables into the home bin directory: ~/bin
37bins="/usr/local/bin:~/bin"
38
39# You need to set the hostname to get the correct configuration loaded.
40# On MacBook,
41# sudo hostname WhiteHusky"
42# sudo scutil --set LocalHostName WhiteHusky
43# sudo scutil --set ComputerName WhiteHusky
44# sudo scutil --set HostName WhiteHusky
45# In System Preferences/Sharing change 'Computer Name' to WhiteHusky if it's not already changed.
46# In your local network configuration, rename the name provided by DHCP.
47# On Ubuntu Linux, to change the hostname permanently,
48# hostnamectl set-hostname Gauss
49
50# Find out the hostname. In cygwin bash, strip off the trailing \r introduced.
51# The alternative is to use tr -d '\r'
52hostname=`python3 -c "import platform; print( platform.node() )" | sed 's/^[ \r\n\t]*$//'`
53#echo "hostname=|${hostname}|"
54
55# Find out which operating system we are running on: macOS, Linux, Windows/Cygwin, etc.
56uname=`uname -s`
57#echo "uname=|${uname}|"
58
59# macOS. Tested on my MacBook Pro laptop mid-2015 model with Intel x86_64 architecture.
60if [ "${uname}" == "Darwin" ] ; then
61 platform="macos"
62# Linux. Tested on my Ubuntu Linux system running on my Cyperpower PC with a 64-bit AMD CPU.
63elif [ "${uname}" == "Linux" ] ; then
64 platform="linux"
65# Cygwin. For cygwin 2.2 64-bit on Windows 10 64-bit. Not tested. From https://en.wikipedia.org/wiki/Uname
66elif [ "${uname}" == "CYGWIN_NT-10.0" ] ; then
67 platform="cygwin"
68else
69 echo "Can't identify OS platform = ${platform}. Exiting .bash_profile"
70 exit 1
71fi
72#echo "Using platform = ${platform}"
73
74if [ "${platform}" == "macos" ] ; then
75 py3bin="/Library/Frameworks/Python.framework/Versions/3.13/bin"
76 #printf "Using macOS System Python version path = ${PATH}\n"
77# Linux. Tested on my Ubuntu Linux system running on my Cyperpower PC with a 64-bit AMD CPU.
78elif [ "${platform}" == "linux" ] ; then
79 py3bin="/usr/local/bin:${HOME}/.local/bin"
80 #printf "Using Ubuntu Linux Python version path = ${PATH}\n"
81elif [ "${platform}" == "cygwin" ] ; then
82 py3bin="/usr/local/bin"
83 #printf "Using Cygwin Linux Python version path = ${PATH}\n"
84fi
85
86# Augmented path.
87PATH="${py3bin}:${bins}:${PATH}"
88#echo "Augmented path = ${PATH}"
89export PATH
90
91if [ "${platform}" == "macos" ] ; then
92 # Not quite the final path -- For macOS, add the path to brew and add export brew's environment variables.
93 # To see help documentation on this, run
94 # /opt/homebrew/bin/brew -h shellenv
95 eval "$(/opt/homebrew/bin/brew shellenv)"
96fi
97
98# CMake tool used for Blender.
99cmakebin="/Applications/CMake.app/Contents/bin/"
100
101# Latest version of make and ack.
102makebin="/usr/local/bin"
103
104# Final path.
105PATH="${HOME}:${makebin}:${cmakebin}:${PATH}"
106#echo "Final path = ${PATH}"
107export PATH
108
109# On Ubuntu Linux, run the Python virtual environment.
110if [ "${platform}" == "linux" ] ; then
111 #echo "Linux: set up Python virtual environment for all terminal windows"
112 if [[ -f ~/.VENV/bin/activate ]] ; then
113 source ~/.VENV/bin/activate # This was commented out by conda initialize
114 echo "Entering `python3 -V` virtual environment at ${VIRTUAL_ENV}. Type deactivate to exit."
115 else
116 echo "WARNING: No Python virtual environment on system. Recommend you set one up."
117 fi
118fi
119
120# Make sure Python 3 is installed on your system. Get the version and redirect from stderr to stdout.
121python_version=`python3 -V 2>&1`
122
123# Delete minor versions (numbers after the first dot), and spaces, e.g. Python 3.13 => Python3
124python_version_stripped=`echo ${python_version} | sed 's/\.[0-9]*//g' | sed 's/[ \r]//g'`
125
126#echo "Python version ${python_version} was detected"
127#echo "stripped version = ${python_version_stripped}"
128
129# Check the version and give help.
130if [ "${python_version_stripped}" != "Python3" ] ; then
131 echo "WARNING: Calling o l d python version ${python_version} stripped ${python_version_stripped} from `which python` in path $PATH"
132fi
133
134# Default settings.
135ls_color_option="-G"
136desk_dir="${HOME}/Desktop"
137thumb_dir="/Volumes/ALNILAM"
138extra_bin_path="/usr/local/bin"
139
140#------------- Export base directories for use by other programs -------------
141
142# The root directory has /Sean under it and /Sean/WebSite underneath that.
143export desk_dir
144export thumb_dir
145
146#echo "Root dir |${desk_dir}|, thumb dir |${thumb_dir}|, desk_dir |${desk_dir}|"
147
148#------------- Directory Shorthands -------------
149
150# Top level directories
151sean_dir="${desk_dir}/Sean"
152app_dir="${desk_dir}/App"
153export sean_dir
154export app_dir
155
156# Level 1 directories.
157arts_dir="${sean_dir}/Arts"
158business_dir="${sean_dir}/Business"
159family_dir="${sean_dir}/Family"
160science_dir="${sean_dir}/Sciences"
161web_dir="${sean_dir}/WebSite"
162export arts_dir
163export business_dir
164export family_dir
165export science_dir
166export web_dir
167
168# Quickly cd to subdirectories by typing cd subdir.
169# Need . in the list to avoid having to put ./ in front of directories.
170export CDPATH=.:~:${sean_dir}:${pp_src_dir}
171
172# Mac system tweaks.
173if [ "${platform}" == "macos" ] ; then
174 # Show hidden files in finder (needs a relaunch of finder).
175 defaults write com.apple.finder AppleShowAllFiles TRUE
176
177 # Screen shots are smaller JPG image files instead of PNG image files.
178 defaults write com.apple.screencapture type jpg
179 # You can bring up screencapture app using Command-SHIFT-5 and setting location to ~/Downloads
180
181 # XCode location.
182 # Some apps like opendiff, launched from git difftool will need to know this.
183 export DEVELOPER_DIR=/Applications/Xcode.app
184fi
185
186# Finish up the aliases.
187source .bashrc