- How to Add a New Path to PATH at Command Line the Right Way
- Adding a Directory to PATH
- How to Add Multiple Paths to PATH
- Setting PATH in Shell Profile
- Question: Q: Adding something to my $PATH permanently
- Question: Q: entering a file path into Finder or elsewhere?
- Helpful answers
- Show Full Directory Path in Mac OS X Finder Window Title Bars
- How to Display the Full Path in Mac Finder Window Titlebars
- Revert Back to the Titlebar Default and Hide the Full Path
How to Add a New Path to PATH at Command Line the Right Way
The user path is the series of directories that command line programs are searched in order to run. For example, if you type ‘iostat’ into the terminal, then iostat will be run from /usr/sbin because “/usr/sbin” is part of your $PATH. Accordingly, users who frequently use the command line may need to adjust or add new paths to their terminal so that commands can execute properly.
Perhaps obvious by now, modifying the PATH is aimed at more advanced users and developers who are using the Terminal and spending a lot of time at the command line. Average Mac users typically have no need to change, add, or otherwise adjust this in Mac OS X. Speaking of Mac OS X, while this is obviously Mac centric, you can use this same trick to add a PATH to your shell in Linux too, as well as most other unix flavors.
Before getting started, you might want to see the existing $PATH just in case you mess something up, that way you can easily restore to it by exporting using the same commands. To check the current $PATH simply type: “echo $PATH”
Adding a Directory to PATH
The easiest way to add a new path to $PATH (the environment variable) is with the export command. In this example we’ll add “
/opt/bin” to the user PATH with export:
You can run that directly from the command line, then check the $PATH with echo to show that it has been added like so:
This should return something like the following, note the newly added
/opt/bin directory at the end:
How to Add Multiple Paths to PATH
Just as multiple paths can be stored and strung together in $PATH in accordance to their search priority, you can also add new paths this way as well. We’ll use the same example as before, but this time also add the
Setting PATH in Shell Profile
Keep in mind that for changes to PATH to persist, you’ll want to add them into
/.profile, .zshrc, or
/.bash_profile, depending on which shell you use. Use your favorite text editor to do that, whether it’s nano, emacs, or vim. If you’re getting complicated, it’s a good idea to add comments to the .profile to keep things easily scannable:
#Adding opt bin and dev bin to PATH for fun
export PATH=$PATH:
Bash is the default shell in many versions of Mac OS X, but zsh is the default in later modern releases, and of course there are other shells like sh, ksh, and tcsh are also bundled with the Mac. Changing the Mac OS X shell is a very easy process either with chsh, or within Terminal and/or iTerm2 preferences.
Источник
Question: Q: Adding something to my $PATH permanently
Hi folks. I want to add /usr/local/bin to my $PATH, permanently. After reading the threads in here, I still am confused about how to do it.
This is what I am trying:
PATH=/usr/local/bin:$PATH
export $PATH
So when I do this:
. it comes back fine. Then I close the window, she goes back to the normal value without /usr/local/bin.
Any ideas? I’m running the bash shell.
G5 1.8/Mini 1.67/Black MacBook/G3 300/PB180c/Mac SE/iMacs & blah blah blah, Mac OS X (10.4.10), iPhone? Heck I’m still giggly about MultiFinder!
Posted on Jun 26, 2007 4:57 PM
Sorry for the confusion, but I’m totally confused.
What do I do? I tried the single statement with
«echo» and the word «export» showed up in my .bashrc
file for some reason.
I’ve never done any of this before, and I’ve been
given 3 files to create, with 2 ways of exporting to
such a file. Can we focus on one way of doing
things, to make it clear?
When a bash shell starts up, it reads several startup files: .bashrc, .bash_profile, and possibly .profile and .login. (I have no idea why there are so many options; personally, I use the /bin/tcsh shell and put all of my startup command in a .cshrc file.)
In any case, you should be fine putting these commands in either .bashrc or .bash_profile. First, let me break down the echo command that was recommended to you:
echo «export PATH=\»/usr/local/bin:$PATH\»» > .bash_profile
First, as you probably guessed, echo just repeats its argument, evaluating any shell variables. If you had just typed echo «export PATH=\»/usr/local/bin:$PATH\»», then the quoted string would have just been printed out to the terminal. However, the ‘>’ is the redirect operator, and it sends the output from a command to a file, in this case .bash_profile. (One thing to note is that using ‘>’ will overwrite an existing file; it’s often better to use the ‘>>’ operator instead, which just appends the output to the end of the existing file.)
Back to solving your problem: open up .bash_profile in a text editor. (If you’re using TextEdit, you can do this at the command line with «open -a /Applications/TextEdit.app
/.bash_profile».) Add the line:
to the file. Save the file and open up a new terminal, then type «echo $PATH» to see if it worked correctly.
MacBook C2D (home), PowerMac Dual G5 (work) Mac OS X (10.4.10)
Источник
Question: Q: entering a file path into Finder or elsewhere?
can anyone help me if there are one or more ways to find a path like this in finder or other software? i have recently realized that i don’t know how to take a file path such as this and then get my mac to show me where this is without «manually» finding it myself. also, i would love any other info on this type of topic or closely related topics if there are any that a new user should be aware of.
/Users/mini_me/Library/Application Support/Postbox/Profiles/jaw8jgkk.default/Mail/Local Folders
Posted on Apr 28, 2012 5:35 PM
You can type Command + Shift + g while in any Finder window or select «Go to Folder…» from the «Go» menu & type in or paste in a filepath. Press the «Go» button & you are there.
Posted on Apr 28, 2012 6:57 PM
Helpful answers
CMD+Shift+g means to hold down the command & shift keys & then tap the «g» key. This shortcut is built into the Finder; you don’t need to add it.
You can see this indicated in Finder’s «Go» menu: next to «Go to Folder…» you will see «⇧⌘G» to help you remember this keyboard shortcut.
The hollow up arrow is the system wide menu symbol for the shift key. You will also sometimes see the ⌥ symbol (for the option key) & the ^ symbol (for the control key) in menus. They are all modifiers keys that you hold down while typing other keys to modify their behavior.
Apr 29, 2012 3:10 PM
There’s more to the conversation
Loading page content
Page content loaded
You can type Command + Shift + g while in any Finder window or select «Go to Folder…» from the «Go» menu & type in or paste in a filepath. Press the «Go» button & you are there.
Apr 28, 2012 6:57 PM
Apr 28, 2012 7:25 PM
Can I please ask you where i find this CMD+Shift+g in the MacOS? I mean, presumably I can customize this if I want and I am not finding it in the preferences under Keyboard Shortcuts.
Apr 29, 2012 2:39 PM
CMD+Shift+g means to hold down the command & shift keys & then tap the «g» key. This shortcut is built into the Finder; you don’t need to add it.
You can see this indicated in Finder’s «Go» menu: next to «Go to Folder…» you will see «⇧⌘G» to help you remember this keyboard shortcut.
The hollow up arrow is the system wide menu symbol for the shift key. You will also sometimes see the ⌥ symbol (for the option key) & the ^ symbol (for the control key) in menus. They are all modifiers keys that you hold down while typing other keys to modify their behavior.
Apr 29, 2012 3:10 PM
thank you very much.
i am new to the OS and trying to get caught up on a couple of things.
so this is a «hard-coded keyboard shortcut» that is basically embedded into the OS and I cannot change it and the ones that I can change are located in the Preferences Keyboard Command section is that right?
i mean, the ones I can change i can see in the Preferences and the ones that I cannot change and they are listed here is that correct?
Apr 29, 2012 3:17 PM
That particular keyboard shortcut is coded into the Finder, which is an application even though we don’t usually think of it that way. In other apps, it might do something else, or nothing at all. For instance, in Safari, «⇧⌘G» is the shortcut for finding the previous instance in a search (it’s on the «Find» menu item of the «Edit» menu).
You are right about the Keyboard Shortcuts section of the Keyboard system preference. Note that you can also create shortcuts as well as change ones that appear there, & they can be either «global,» applying to all apps or specific to a selected app. However, the shortcuts you create will not override ones coded into an app.
If you click the purple question mark icon in the preference, the help topic that appears will give you a little more info about this.
Источник
Show Full Directory Path in Mac OS X Finder Window Title Bars
Have you ever wished you could see the complete file system path in the titlebar of a Finder file system window? Well you can use a secret setting in Mac OS X to display the path in the titlebars of windows. The geekier Mac users amongst us and those familiar with the unix world should really appreciate this, but really it’s useful for anyone who just likes to know where they are currently located within the file system.
To change the Finder window titlebars to display the full directory path, you’ll need to use a defaults command string entered into the Terminal.
How to Display the Full Path in Mac Finder Window Titlebars
TO get started, you’ll need to launch the Terminal app on the Mac (found in the /Applications/Utilities/ folder), and then enter the following defaults command string onto a single line:
defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
Hit the return key for the defaults string to execute.
Now you’ll want to kill the Finder for changes to take effect, this causes the Finder to quit and then relaunch itself:
Again hit the return key.
You can also make this entire command sequence a bit easier by combining the the two into a single command string, just be sure the syntax is on a single line when executed looking like so:
defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES;killall Finder
Entered into a single command line, that will not only execute the proper defaults command but also restart the Finder, thereby enabling the full path to be displayed in the titlebar.
Once the Finder has refreshed you’ll instantly see the difference when you start navigating to remote paths in the Mac OS X file system.
Like anything else performed with a defaults string in Mac OS X, this setting can be reversed if you’d prefer to return to only showing the active finder window as the titlebar names in Finder.
Revert Back to the Titlebar Default and Hide the Full Path
To disable the full path title bars and revert back to the default, simply go back to the Terminal app and repeat the command with NO instead of YES as the operator:
defaults write com.apple.finder _FXShowPosixPathInTitle -bool NO
This works with any version of OS X beyond 10.5, including Mac OS X 10.6, 10.7, 10.8, OS X 10.9 Mavericks, MacOS El Capitan 10.11 Mac OS Sierra 10.12, Yosemite 10.10, MacOS High Sierra, MacOS Mojave 10.14, and newer.
Источник