Oct 16, 2019 Once I moved to Mac, I changed my shell to use zsh using Oh My Zsh due to the rich experience it brings to the terminal. I was delighted to see all these themes and plugins, and then started looking for a theme that provided the same information posh-git prompt provided. Mac 终端默认 shell 为 bash。zsh 可能是目前最好的 shell ,至于好在哪里可自行百度。本文主要介绍使用 zsh 以及 oh-my-zsh 的配置。.
Estimated reading time: 3 minutes Compose comes with command completionfor the bash and zsh shell.
Install command completion
Bash
Make sure bash completion is installed.
Linux
- On a current Linux OS (in a non-minimal installation), bash completion should beavailable.
- Place the completion script in
/etc/bash_completion.d/
.
Mac
Install via Homebrew
- Install with
brew install bash-completion
. - After the installation, Brew displays the installation path. Make sure to place the completion script in the path.For example, when running this command on Mac 10.13.2, place the completion script in
/usr/local/etc/bash_completion.d/
. - Add the following to your
~/.bash_profile
: - You can source your
~/.bash_profile
or launch a new terminal to utilizecompletion.
Install via MacPorts
- Run
sudo port install bash-completion
to install bash completion. - Add the following lines to
~/.bash_profile
: - You can source your
~/.bash_profile
or launch a new terminal to utilizecompletion.
Zsh
Make sure you have installed
oh-my-zsh
on your computer.With oh-my-zsh shell
Add
docker
and docker-compose
to the plugins list in ~/.zshrc
to run autocompletion within the oh-my-zsh shell. In the following example, ..
represent other Zsh plugins you may have installed.Without oh-my-zsh shell
- Place the completion script in your
/path/to/zsh/completion
(typically~/.zsh/completion/
): - Include the directory in your
$fpath
by adding in~/.zshrc
: - Make sure
compinit
is loaded or do it by adding in~/.zshrc
: - Then reload your shell:
Available completions
Depending on what you typed on the command line so far, it completes:
- available docker-compose commands
- options that are available for a particular command
- service names that make sense in a given context, such as services with running or stopped instances or services based on images vs. services based on Dockerfiles. For
docker-compose scale
, completed service names automatically have “=” appended. - arguments for selected options. For example,
docker-compose kill -s
completes some signals like SIGHUP and SIGUSR1.
Enjoy working with Compose faster and with fewer typos!
Compose documentation
fig, composition, compose, docker, orchestration, cli, referenceThe era of .NET developers being constrained on using only Windows as a platform is gone. (At least for ASP.NET). That might be very cool to some, but also scary for others. Fear of change is true. Nevertheless, it's definitely time (if not yet) to get out of the comfort zone and get your feet wet. Being able to work with .NET on Linux/Mac is one of the points that makes me agree 100% with Nick Craver that .NET Core is the future.
After reading Scott Hanselman's blog post last week, I decided to setup WSL on my laptop. If you don't know what Windows Subsystem for Linux is (WSL from now on in this post), I recommend reading this before.
The TL;DR of that link is:
WSL lets developers run Linux environments -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a virtual machine.
While setting it up on my machine was very easy, I didn't want to stay with the boring Windows bash shell. Guys at work use Mac's with oh-my-zsh and boy that made me pretty jealous. It was not that straightforward to make it all work though. So hopefully, this post will help me and others in the future. Here's what we are going to do:
- Enable WSL on Windows 10
- Install zsh + oh-my-zsh
- Configure zsh and oh-my-zsh
- Change Themes and colors
- Adding Bash on Ubuntu task in ConEmu*
Enable WSL on Windows 10
This is pretty straightforward to set up, Just follow the instructions here to get Ubuntu running. After you are in, update the packages, by running:
sudo apt-get update
. When all is working, you can continue to the next step.Installing zsh
Open the Ubuntu app installed from the App Store. We will now install zsh:
After installing it, type
zsh
. zsh will ask you to choose some configuration. We will do this later on while installing oh-my-zsh
, so choose option 0
to create the config file and prevent this message to show again.Installing oh-my-zsh
Before all we need to have
git
installed:Then, use
curl
to install oh-my-zsh:This will clone the repo and replace the existing
~/.zshrc
with a template from oh-my-zsh
.Configuring zsh/oh-my-zsh
First, we need to make sure
zsh
is executed by default for Bash on Ubuntu. This is not mandatory, but if not done you need to type zsh
every time. For this, edit the .bashrc
file with nano: nano ~/.bashrc
and paste this right after the first comments:Save it
Ctrl + shift X
and restart your Ubuntu shell. You should be on zsh by default now.Changing the Theme of oh-my-zsh
oh-my-zsh has several nice Themes. It's worth checking them out. For this tutorial, I'm going to use the awesome agnoster.
Save it and restart your Ubuntu shell again.
Now was the tricky part while I was doing this on my laptop. After installing the theme, I got a totally broken shell (as shown in the image), with weird fonts and missing icons. That was expected due to missing Powerline Fonts, but even after installing them on Ubuntu the Theme was still broken. I tried several things and couldn't make it work. Since we will run it with ConEmu, I didn't want to spend more time on it. The Ubuntu shell is very limited anyway so. not a big deal.
Installing missing Powerline Fonts
We need to install the Powerline fonts in our Windows to make the agnoster theme work. Follow these steps:
- Clone the powerline repository on Windows
- Open an admin PowerShell, navigate to the root of the repo and run this:
This will install all the fonts on your Windows. You might get an error from PowerShell blocking you from running the script. Check this out if it happens with you. Make sure to reverse the policy after.
Changing directory colors
How to measure caster in jeep jl. The directory colors for zsh is awful. If you followed along, by now you should have an ugly yellow or dark blue background on folders when
ls/ll
. Luckily, we can change that by installing a Solarized Color Theme from here. Follow these steps:- Pick a theme from the GitHub repo (I'm using dircolors.ansi-dark since I use a dark shell).
- Download the file making sure to put it in the user's home:
- Edit your
~/.zshrc
and paste this:
We have nice colors now :)
Setting Bash on Ubuntu task in ConEmu
Open ConEmu, and go to
Settings
. Navigate on the left-menu: Startup > Tasks
. There, click at the +
button at the bottom.- Add a name for the task. Anything will suffice. I used
bash::ubuntu
to group Ubuntu into the bash tasks. - On
Task parameters
choose an icon for the task. I picked the Ubuntu icon app that is buried under some very long path. but any .ico will work. You can leave it blank if you don't care. - For the
command
use this%windir%system32bash.exe ~ -cur_console:p
. This will start bash under the user home directory. Since we already configuredzsh
to run by default, this is enough.
Oh My Zsh For Mac Windows 10
Open the new task on ConEmu and.. Voalá!
![Zsh Zsh](https://maxmasnick.com/media/2011-12-28_developer_tools_for_mac_2011/zsh_shadow2.jpg)
Nice command look, lots of git shortcuts and much more productivity. Couldn't enjoy this more.
Additional links
Here are a few other things you might want to look:
Oh My Zsh For Mac
- oh-my-zsh cheatsheet: Lots of commands to improve your productivity
- Colors page on ConEmu: How to change ConEmu color scheme (If you liked mine, I'm using Solarized (Luke Maciak) with Meslo LG M DZ for Powerline console font)
- Understand why you're not supposed to touch Linux files using Windows apps: https://blogs.msdn.microsoft.com/commandline/2016/11/17/do-not-change-linux-files-using-windows-apps-and-tools/
Oh My Zsh Macos Install
Would be cool to see what other things you use on your setup. Just let me know in the comments!