- Mac Os Terminal Color Scheme
- Macos Terminal Color
- Change Terminal Color Mac
- Monokai Theme For Mac Terminal
- Customize Mac Os Terminal
I just recently had the opportunity to sit with Aaron Nelson and go through some really cool Powershell features, and I’m certainly going to spend time getting to know Powershell a lot better. If you didn’t know, Powershell isn’t exclusive to Windows anymore – you can actually run a basic set of Powershell features, called Powershell Core, on Mac OS and Linux as well.
I would like to set the Max OS X Terminal theme for Ubuntu Terminal. I really like the fonts and the colors. This is how the Mac Terminal does look: Image source. There are few things that I want to see in the Ubuntu Terminal: I want to replace username@desktop:/Dropbox$ with the username and the computer name in this format: desktop:Dropbox. Here is a way you do that: Open the Terminal.app Select 'Terminal' Menu then 'Preferences.' Select the 'Profiles' tab (labelled 'Settings' before Yosemite) Click and highlight a theme listed under Profiles. Press the 'Default' button near the bottom of the window. Open a new Terminal window, it.
But there’s a problem.
By default, running the “pwsh” command just starts Powershell Core in a regular terminal window. The first thing you’ll notice is that this doesn’t really play well if you’re using a white background, as the output is often light grey, yellow or even white.
So wouldn’t it be cool if we could launch our Powershell Core in the stylish blue world of bliss that Windows users have become so accustomed to?
Setting up a color profile
You probably already know that you can customize the Mac Terminal to death, and you may even have noticed that you can create different profiles for different purposes:
What you can do is, you can create a separate profile for your Powershell Core stuff, customize all those colors, fonts, and what-not. But here’s where it gets funkier:
You can set a custom command to start when you open a terminal window with this profile: enter pwsh in the “Run command” field at the top, and now, every time you open a window with this profile, it starts Powershell Core automatically, saving you all of five keystrokes.
The “Run inside shell” checkbox needs to be enabled!
In fact, you may even want to put “pwsh; exit” (without the quotes) in the “Run command” field – this will terminate the bash shell automatically when the pwsh process ends, so typing “exit” in Powershell will close the window.
Another slight annoyance is that when you want to close the window, technically the “pwsh” process is still running (unless you type “exit”), so you’ll get a friendly confirmation dialog that you’ll have to deal with:
To make this window go away, and save you another five keystrokes, look at the bottom of the “Shell” tab of the “Preferences” window, in the “Ask when closing” section. If you add “pwsh” to that list of applications, the terminal won’t ask you for confirmation if you want to close the window.
Obviously, that warning is there for a reason, so it’s really your call if you want to do this.
The result
Now, when you open Terminal, you can select “New Window” -> “Powershell” from the “Shell” menu…
… and voilà:
If you spend any time in Terminal on your Mac, it’s worth customizing the look and feel of the application. Here are some of the most interesting ways you can customize Terminal with themes, colorization, and first-run commands.
Tweaking Terminal’s Theme
Terminal has the built-in ability to theme your shell windows, but you’d never know it by looking at the default white screen.
Navigate to “Terminal -> Preferences” from Terminal’s menu bar.
In the Preferences window select the “Profiles” tab. These options will adjust the appearance of new Terminal windows.
Adjustable appearance settings include background and text color, text-rendering options, text size and typeface, cursor type, selection color, and ANSI colors. ANSI colors are used when a Terminal command displays colored output but won’t appear otherwise.
You’ll notice a number of pre-existing profiles in the menu on the left pane. You can choose one of these or click the “+” button at the bottom of the pane to create a new profile. Profiles are the containers for your settings, so you may want to create a personal profile before tweaking anything.
When ready, set your new profile as your default by clicking the “Default” button at the bottom of the profile pane. All new Terminal windows will now open in this profile.
You can also open Terminal windows in a specific profile from “Shell -> New Window,” which allows you to select the profile for the new shell.
Login Commands
Terminal can run specific shell commands when a shell window is open. These can be assigned on a per-profile basis, so different profiles execute different commands.
Open Terminal’s preference window from “Terminal -> Preferences,” and click on the “Shell” tab.
Under “Startup” check the box next to “Run Command,” then type the shell command you want to execute on startup. Leave “Run inside shell” checked below it.
Mac Os Terminal Color Scheme
This setting will auto-save to the associated profile and run the next time a shell is opened in that profile. To turn off the startup command, uncheck the box next to “Run command” to disable.
Macos Terminal Color
Colorizing Your Prompt
By editing “.bash_profile,” we can colorize the text in your Terminal prompt. For the neophyte, that’s the fixed text that appears when you open a new shell to the left of the text entry cursor.
Open your “.bash_profile” in nano with the command below:
With “.bash_profile” open, we will want to add a new line that starts with:
Change Terminal Color Mac
After the equal sign we will include our ANSI color codes. Your PS1 also needs to contain any escape sequences for variables like user name, host name, current working directory, and so on. For the prompt in the screenshots, I’ve used the colorization rules below:
That prompt includes numerical ANSI color codes as well as escape sequences for the user (u), host (h), and present working directory (W). For a detailed explanation of how this gibberish works, reference our post on colorizing your shell prompt in Linux. You will also want a chart of the xterm-256-compatible ANSI color codes.
Colorize and Format Terminal Text
Typed text in Terminal can be formatted via profile settings or directly through typing shell commands.
To attach a text color to a profile, use the text color setting in “Terminal -> Preferences -> Text.”
To colorize text temporarily, use something like the command below:
Monokai Theme For Mac Terminal
This will have the following result.
Let’s explain what we just did with the above command:
printf
is a Terminal command that prints text to the Terminal’s standard output, a.k.a. the command line.'
opens the printf stringe
escapes the non-printing characters which specify the color[31m
is the ANSI color code for red textHello World
is our string literale[0m
clears formatting so text after the string literal does not appear colorizedn
prints a new line'
closes the printf string
Customize Mac Os Terminal
If you want the text to continue to appear colorized, leave off the e[0m
. To end formatting, print e[0m
to standard output with printf
.
Any of the ANSI color codes can be used here; see the above-linked guide for more details.
Typed text can be formatted beyond colorization. If you’re an insane person, you can make the text blink!
Change Window Title
By default, Terminal will show the present working directory, active process, and viewport size in your Terminal window’s title bar.
The title bar’s contents can be adjusted in the “Window” tab of Terminal’s preferences.
Open Terminal’s preference window from “Terminal -> Preferences,” and select the “Window” tab.
Adjust the settings near the top to modify the window’s title. You can see the results reflected in any currently-open shells running the profile you’re editing.
Conclusion
These are only the “greatest hits” of Terminal customization. There is much more you can do to customize your Terminal. Explore the Terminal Preferences menu to find more.
If you want to explore Terminal further, you might be interested in the following posts: