Skip to content

Instantly share code, notes, and snippets.

@kevin-smets
Last active September 17, 2024 13:07
Show Gist options
  • Save kevin-smets/8568070 to your computer and use it in GitHub Desktop.
Save kevin-smets/8568070 to your computer and use it in GitHub Desktop.
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

How to install

iTerm2

brew install --cask iterm2

Or, if you do not have homebrew (you should ;)): Download and install iTerm2

iTerm2 has better color fidelity than the built in Terminal, so your themes will look better.

Get the iTerm color settings

Just save it somewhere and open the file(s). The color settings will be imported into iTerm2. Apply them in iTerm through iTerm → preferences → profiles → colors → load presets. You can create a different profile other than Default if you wish to do so.

Oh My Zsh

More info here: https://github.com/robbyrussell/oh-my-zsh

Install with curl

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

When the installation is done, edit ~/.zshrc and set ZSH_THEME="agnoster" for the default look. Or better yet, go for Powerlevel10k.

Powerlevel9k / Powerlevel10k

Why Powerlevel10k? Well, because it's a drop-in replacement for Powerlevel9k, just a lot faster to render your prompt. ls feels fast again!

So if you prefer the Powerlevel10k look with added info such as exit codes and timestamps on the right, run:

git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k

Then edit your ~/.zshrc and set ZSH_THEME="powerlevel10k/powerlevel10k". Once you do so, when you start a new terminal session, the Powerlevel10 configure wizard will be launched to set your prompt, beware, there are many many options!

Powerlevel10k offers a whole lot more and is extremely configurable, best is to check its project page.

If you want to trigger the configuration wizard immediately, simply run p10k configure to discover all options, which are plentiful.

Install a patched font

If you did not go with Powerlevel10k or you want another font, read on:

Open the downloaded font and press "Install Font".

Set this font in iTerm2 (iTerm → Preferences → Profiles → Text → Font), in the dropdown select the desired Font. You will see it change on the fly.

Restart iTerm2 for all changes to take effect.

Further tweaking

Things like

  • auto suggestions
  • word jumping with arrow keys / natural text editing
  • syntax highlighting
  • visual studio code config

can be found in the section below.

Auto suggestions (for Oh My Zsh)

Auto suggestions

Just follow these steps: https://github.com/zsh-users/zsh-autosuggestions/blob/master/INSTALL.md#oh-my-zsh

If the auto suggestions do not appear to show, it could be a problem with your color scheme. Under "iTerm → Preferences → Profiles → Colors tab", check the value of Black Bright, that is the color your auto suggestions will have. It will be displayed on top of the Background color. If there is not enough contrast between the two, you won't see the suggestions even if they're actually there..

Enable word jumps and word deletion, aka natural text selection

By default, word jumps (option + → or ←) and word deletions (option + backspace) do not work. To enable these, go to "iTerm → Preferences → Profiles → Keys → Key mappings → Presets... → Natural Text Editing → Boom! Head explodes"

Syntax highlighting

Clone the repository:

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

Activate the plugin in ~/.zshrc:

plugins=( [plugins...] zsh-syntax-highlighting)

Restart iTerm2 for all changes to take effect.

Visual Studio Code config

Installing a patched font will mess up the integrated terminal in VS Code unless you use the proper settings. You'll need to go to settings (CMD + ,) and add or edit the following values:

  • for Source Code Pro + Font Awesome: "terminal.integrated.fontFamily": "'SourceCodePro+Powerline+Awesome Regular'". The single quotes are important! Restart VS Code after the config change.
  • for Source Code Pro: "terminal.integrated.fontFamily": "Source Code Pro for Powerline"
  • for Meslo: "terminal.integrated.fontFamily": "Meslo LG M for Powerline"
  • for other fonts you'll need to check the font name in Font Book. You can right click on them on select "Show in Finder" to get the exact name.

You can also set the fontsize e.g.: "terminal.integrated.fontSize": 14

@amiamitswe
Copy link

Screen Shot 2022-03-08 at 5 25 50 PM

On my screen, whenever I press enter it shows > rather than the path itself.
I want when I press enter it shows the result after the path URL, and then a new path URL will appear to take the next command.

@romkatv
Copy link

romkatv commented Mar 8, 2022

@amiamitswe Run p10k configure. When it asks whether you want to enable transient prompt, answer No. It's a good feature by the way.

@amiamitswe
Copy link

@romkatv Thanks a lot !

@salomaos
Copy link

salomaos commented Apr 7, 2022

zsh: command not found:

What I did to solve this
Open the .bash_profile, copied the export PATH=... and pasted in the .zshrc file.

@Jihad
Copy link

Jihad commented Apr 16, 2022

it's still not clear to me how I could fix this icon problems. i have downloaded the fonts and set them to it.

~/research  on sidod +10 !8 ?199

what s +10, !8, and ?199 and more importantly, how I can fix it?

Screen Shot 2022-01-05 at 2 42 25 PM

@monajalal Not sure if others response still not clear, but the "?, !..etc" are not meant to be icons, they are actually a (plus sign, question mark..etc), with different meanings for each.

So based on the link shared to you and your screenshot:
+10 = you have 10 staged changes
!8 = you have 8 unstaged changes
?199 = you have 199 untracked files

@shant0602
Copy link

If I do a git banch or git diff it opens a vi type screen which has to be exited by :q. Is there any way I can get it listed in the same screen?

@ZoltonMD
Copy link

ZoltonMD commented May 5, 2022

@shant0602 , I'm not sure I've got your issue, but if I do, you can change pager for your repository, for example to cat with command: git config core.pager cat. Also you can do it globally for all repositories with --global option

@mxnmike
Copy link

mxnmike commented May 17, 2022

Any luck finding this path? I couldn't find it on mine...

Screen Shot 2022-05-17 at 9 22 44 a m

@kevin-smets
Copy link
Author

@mxnmike fixed it in the readme, you can now find it under "... - Keys - Key mappings - Presets..."

@markplewis
Copy link

Does anyone know if it's possible for the iTerm colour settings to override the terminal prompt segment colours defined by the powerlevel10k theme in ~/.p10k.zsh? The ZSH theme's colours seem to take priority over iTerm's colours.

@markplewis
Copy link

Thanks @romkatv!

@hatruongauntie
Copy link

For the color of ZSH AUTO SUGGEST, you can edit your ~/.zshrc and change/add the variable:

ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=5'

(fg stands for Foreground and you can test the value that fits your eyes)

@eijnehc
Copy link

eijnehc commented Jun 12, 2022

plugins=( [plugins...] zsh-syntax-highlighting) did not work for me. I have to specify the full plugins for it to work. In my case plugins=( git zsh-syntax-highlighting)

@KarthikRajashekaran
Copy link

How to resolve the issue i see in VSCode Terminal
image

@romkatv
Copy link

romkatv commented Jun 14, 2022

@KarthikRajashekaran
Copy link

@joban-jit
Copy link

Hello everyone,
When I do ls command, some folders are highlighted, anyone know why?
Thanks
Found any solution to this?

@romkatv
Copy link

romkatv commented Jun 24, 2022

@joban-jit Add this at the bottom of ~/.zshrc:

zmodload zsh/terminfo

export LS_COLORS='fi=00:mi=00:mh=00:ln=01;36:or=01;31:di=01;34:ow=04;01;34:st=34:tw=04;34:'
LS_COLORS+='pi=01;33:so=01;33:do=01;33:bd=01;33:cd=01;33:su=01;35:sg=01;35:ca=01;35:ex=01;32'
if (( terminfo[colors] >= 256 )); then
  LS_COLORS+=':no=38;5;248'
else
  LS_COLORS+=':no=1;30'
fi

export TREE_COLORS=${LS_COLORS//04;}
export LSCOLORS='ExGxDxDxCxDxDxFxFxexEx'

@Rdgh1583
Copy link

Screen Shot 2022-07-14 at 5 19 49 PM

how can i display my name?

@Rdgh1583
Copy link

Screen Shot 2022-07-14 at 5 28 10 PM

getting this

@romkatv
Copy link

romkatv commented Jul 14, 2022

Are you getting this when you click on ~/.p10k.zsh? Don't click on it. Instead, open a text editor and open that file in the text editor.

@Rdgh1583
Copy link

it happens when i open it on text editor

@Rdgh1583
Copy link

open ~/.p10k.zsh then this window prompts

@romkatv
Copy link

romkatv commented Jul 14, 2022

open ~/.p10k.zsh then this window prompts

Don't execute open ~/.p10k.zsh. Instead, start a text editor and open this file from it.

If you are having trouble with this, it may not be good idea to attempt to customize your prompt.

@dproasia
Copy link

The link to the font Source Code Pro + Font Awesome is broken, could you please add the correct link.
Thanks!

@kn-wield
Copy link

kn-wield commented Aug 9, 2022

Bravo! 👏

@joleroi
Copy link

joleroi commented Aug 19, 2022

It seems like the solarized dark theme is available in iterm2 by default. Is that correct?

@mnjit20
Copy link

mnjit20 commented Aug 21, 2022

🥷 Excellent @kevin-smets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment