<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\documentclass[onecolumn,letterpaper,11pt]{article}

%===================================================================
\input{common_latex/common_latex_packages}
\input{common_latex/common_latex_definitions}
\input{common_latex/common_latex_help_format}
%===================================================================

\begin{document}

\begin{labcover}
\labtitle{Help Topic: Augmenting Your Shell Path}
\vspace{0.1in}
\labdate{Spring 2022}
\vspace{0.1in}
\labauth{Michael Benjamin, mikerb@mit.edu}
\labauth{Department of Mechanical Engineering}
\labauth{MIT, Cambridge MA 02139}
\labline
\end{labcover}

\wikidoc{file=Help.CMDPath}
\wikidoc{auth=mikerb@mit.edu}

%====================================================================
\section*{Adding a Directory to Your Shell Path}
%====================================================================

The {\em shell path} is a list of locations your shell program knows about
to look for programs to run. When you type:

\vspace{0.1in}
\begin{consoleverb}
 $ pwd
\end{consoleverb}
\vspace{0.1in}

\noindent
or

\vspace{0.1in}
\begin{consoleverb}
 $ du 
\end{consoleverb}
\vspace{0.1in}

\noindent
The \cmd{pwd} command is located in the \var{/bin} directory and \cmd{du}
is located in the \var{/usr/bin} directory. These locations are conventional
locations most shells users have in their shell paths. But if you add your
own code (as we will in this class) you'll need to know how to augment your
shell path to tell your shell where the new programs reside.

\vspace{0.1in}
\noindent
Adding a directory to your shell path is a very common thing command
line users need to do. Unfortunately the need often comes up for new
users while they're still finding their feet with the command line,
and before they know what a shell {\em environment} is, and sometimes
before they even know how to use a text editor.  Here we focus on the
minimal steps for adding a new directory to the shell path, perhaps
glossing over a few things for the sake of getting it done.

%---------------------------------------------------------------------
\subsection*{Make Sure You Know How to Edit a Text File}

The next step involves a simple edit to a text file. If you know how to 
do this proceed to the next step. 


\vspace{0.1in}
\noindent
If you don't know what a text file is, vs. say a Microsoft Word
document which just has text, then you may not know what a {\em text
editor} is either. Wikipedia has a good entry on this topic. I
recommend giving it a skim. 

\vspace{0.1in}
\noindent
The good news is that you very likely already have a text editor on
your machine. On the Mac it is an application called \cmd{TextEdit}, in the
\var{/Applications/} directory.  In GNU/Linux, it is a called \cmd{gedit} in the
\var{/usr/bin} directory. And, if for some reason those directories are
not in your shell path, don't despair. You can launch these editors by
typing their full path name, or double clicking on them in a GUI like
Finder on the Mac.


\vspace{0.1in}
\noindent
The bad news is that we really don't want to be using editors
like \cmd{gedit} or \cmd{TextEdit} in our class. And we certainly
don't encourage people to launch a text editor from a GUI. We want to
do this all from the command line, and want to use a more powerful
text editor like \var{Emacs} or \var{vi}. But for now, do what you need to do,
just so long as you can make simple edits to a text file so we can get
through the next few steps below.

\vspace{0.1in}
\noindent
If you really do want to hit the pause button here and go get Emacs and 
learn just enough to make and save simple edits, then check out the first
couple emacs help topics on the main help page.

\vspace{0.1in}
\noindent
The main help page:

\noindent
\urlx{https://oceanai.mit.edu/ivpman/help}

\vspace{0.1in}
\noindent
The Emacs Editor help page for MacOS users:

\noindent
\urlx{https://oceanai.mit.edu/ivpman/help/emacs_get_for_osx}



%---------------------------------------------------------------------
\subsection*{Augmenting the Shell Path for \cmd{bash} Users}

If you're a bash user, your configuration is done in a couple files in
your home directory: \var{.bash\_profile},
and \var{.bashrc}. Use \cmd{ls -a} to see them since they are hidden
files. If you don't have these files, I recommend downloading the
example files described earlier, or on the help page:

\vspace{0.1in}
\noindent
\urlx{http://oceanai.mit.edu/ivpman/help/cmdline_shell_environment}
\vspace{0.1in}

\noindent
Otherwise, if you already have the \var{.bashrc} file, edit the file
and put the following two lines at the end of the file.

\vspace{0.15in}
\begin{fileverb}
 PATH=$PATH:/my/full/directory/
 export PATH
\end{fileverb}
\vspace{0.15in}

%---------------------------------------------------------------------
%\subsection*{Augmenting the Shell Path for tcsh users}

%If you're a tcsh user, your configuration is done in a the .cshr file
%in your home directory. Use \cmd{ls} with the \cmd{-a} optiona to see
%it since it is a hidden file. If you don't have this file, I recommend
%downloading the example file described earlier, or on the help page:

%\vspace{0.1in}
%\noindent
%\urlx{http://oceanai.mit.edu/ivpman/help/cmdline_shell_environment}
%\vspace{0.1in}

%\noindent
%Otherwise, if you already have the \var{.cshrc} file, edit the file
%and put the following line at the end.

%\vspace{0.15in}
%\begin{fileverb}
% set path = ( $path /my/full/directory ) 
%\end{fileverb}
%\vspace{0.15in}

%---------------------------------------------------------------------
\subsection*{Verifying Success}

To verify success, pick one of the executables in the directory you added
to the shell path and use the \cmd{which} tool:

\vspace{0.1in}
\begin{consoleverb}
 $ which cmake
 /opt/local/bin
\end{consoleverb}
\vspace{0.1in}

\noindent
Note the returned value may also be something like
\var{/usr/local/bin/cmake}, or \var{/bin/cmake}, or
\var{/usr/bin/cmake}, depending on if your system is MacOS or
GNU/Linux and depending on the particular release of MacOS or
GNU/Linux. The important measure of success is that the above
command does just return without an answer. 

%\noindent
%If unsuccessful, for tcsh users, try typing \cmd{rehash} on the command line
%to update the shell's internal cache of executables.

\end{document}

</pre></body></html>