I was using bash before switching to zsh.
On my ~/.zsh I have export PS1="\w ~ " but it is not making those changes to reflect the prompt. I want my prompt to show something like Documents/Rails_App/views ~
I have opened a new tab and closed re-opened the app.
The first level prompt of Zsh can be set in with either PROMPT, prompt or PS1.
Zsh uses other escapes than Bash. Most notably do they start with % not \. The equivalent to Bash's \w would be %~.
So just putting setting the following line in your ~/.zshrc should do the trick:
PROMPT='%~ ~'
Note: There is (usually) no need to export PROMPT in Zsh - or Bash for that matter.
If it does not work for you, it most likely has to do with Oh-My-Zsh as it already provides its own settings for PROMPT. So you have to make sure that you set PROMPT after Oh-My-Zsh has been sourced.
If you used the template that came with Oh-My-Zsh it should be after this line:
source $ZSH/oh-my-zsh.sh
On Debian distro.
After installing zsh from standard source apt install zsh comment #prompt adam1 inside .zshrc file and reload settings source ~/.zshrc.
Now add custom prompt: PROMPT='Greetings %n '
Image: zsh custom prompt
Use _PROMPT in zsh:
export _PROMPT='%d ~ '
Related
I'm running ubuntu 1804 on windows using the WSL. Everything is set up fine and works correctly. I've also installed ZSH and oh-my-zsh, again this is all good and everything looks like its working fine. Everything except the arrow keys whilst using vim or man pages or some other command line tools.
The up and down keys work on the command line when scrolling through history and also for select commands like nano. Also if I boot into bash rather than zsh the arrow keys do work in vim and man pages, in fact they work everywhere.
If i boot into bash, then switch to zsh on the command line manually the arrow keys then work everywhere.
So my cmder config for zsh
c:/_distros/ubuntu1804/ubuntu1804.exe -c zsh -cur_console:pm
and for bash
set "PATH=%ConEmuBaseDirShort%\wsl;%PATH%" & %ConEmuBaseDirShort%\conemu-cyg-64.exe --wsl -cur_console:pm:/mnt
The one for bash uses the conemu-cyg-64.exe program that comes from conemu which is a symbiont of POSIX enabled pty and WinAPI full-featured terminal.
Apparently you can use this tool with zsh but i cant manage to make it work i get the error
{PID:10592} failed to run shell (2): No such file or directory
{PID:10592} shell: `/usr/bin/zsh` `-l` `-i`
{PID:10592} dir: `/cygdrive/c/Program Files/cmder`
ConEmuC: Root process was alive less than 10 sec, ExitCode=0.
Press Enter or Esc to close console...
and this is the task in cmder
set "PATH=%ConEmuBaseDirShort%\wsl;%PATH%" & %ConEmuBaseDirShort%\conemu-cyg-64.exe /usr/bin/zsh -l -i -cur_console:pm:/mnt
So I think that if i can boot into zsh using conemu-cyg-64 that the cursor keys will probably work in commands like vim and the man pages. Any help or advice getting that working would be brilliant.
EDIT:
On my ubuntu install zsh is installed at /usr/bin/zsh, but there is no file or folder /cygdrive/c/Program Files/cmder
Many thanks to #Maximus for pointing me in the right direction. The answer was right under my nose at the bash on windows page of conemu. A small change to the command i was using before. the zsh needs to go on the end rather than before the --wsl.
The correct task to ensure that cursor keys work on all apps in the terminal is:
set "PATH=%ConEmuBaseDirShort%\wsl;%PATH%" & %ConEmuBaseDirShort%\conemu-cyg-64.exe --wsl -cur_console:pnm:/mnt -t zsh -l
I have been using oh-my-zsh for a while now and the docker plugin as recently stopped working for me for some reason.
I checked my ~/.zshrc file and the plugin is included
plugins=(git colored-man colorize github jira vagrant virtualenv pip python brew osx zsh-syntax-highlighting docker)
I checked the ~/.oh-my-zsh/plugins/docker directory and there is a _docker file in there. Yet when I type docker and press Tab, I get none of the autocomplete shortcuts that I used to get.
I can confirm that my git plugin works just fine but not the docker plugin. Tried doing exec zsh and source ~/.zshrc and restarted my terminal but no luck.
Am I missing something?
You might want to try and remove any .zcompdump-(...) files you may have on your user's home directory - using something like rm ~/.zcompdump* on a terminal, or some file browser - and then reload the .zschrc file with the command source ~/.zshrc or restart the terminal - whichever works best for you. See this
Then see if it works.
It seems oh-my-zsh is not loading plugins/docker/_docker file. You must add it to ~/.zshrc in an another way.
Add these lines to your ~/.zshrc file:
fpath+=($ZSH/plugins/docker)
autoload -U compinit && compinit
For me it was simply the case that I needed to launch Docker for the first time from spotlight on my Mac in order for Docker for Desktop to get the access it needed. Then the docker version command worked just fine.
Follow these steps if you are using oh-my-zsh and autocomplete is not working:
Make the following three links:
ln -s /Applications/Docker.app/Contents/Resources/etc/docker.zsh-completion /usr/local/share/zsh/site-functions/_docker
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-machine.zsh-completion /usr/local/share/zsh/site-functions/_docker-machine
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-compose.zsh-completion /usr/local/share/zsh/site-functions/_docker-compose
Either add autoload -Uz compinit; compinit to .zshrc or run in your shell:
echo "autoload -Uz compinit; compinit" >> .zshrc
In my case: Windows 10 + WSL2 + Hyper
I was having this error because I stopped Docker on Windows... Starting it again makes the error disappear in Hyper (thus, also in ZSH).
No .zshrc changes or additional commands to add inside.
#youhans's solution worked for me permanently. You might have permission issue to make needed adjustment on "zshrc". I have changed the permission to "read and write" and added the code snippet from #youhans's response to the end of "zshrc" file. Now completion system always works.
Before I had to type below snippet in command line whenever open a new terminal.
autoload -Uz compinit && compinit
In my case it occurred because of an alias. I had defined alias docker=docker.exe.
Removing that did it work again.
System & Environment
O.S.: Windows 10 Home, x64
Shell: Zsh (on Gitbash)
I think you may be missing ,'s in between each plugin.
plugins=(git, colored-man, colorize, github, jira, vagrant, virtualenv, pip, python, brew, osx, zsh-syntax-highlighting, docker)
Alternatively you can place each plugin on a separate line:
plugins=(
git
colored-man
colorize
github
jira
vagrant
virtualenv
pip
python
brew
osx
zsh-syntax-highlighting
docker
)
I recently decided to switch from zsh to bash. However, for some reason that escapes me, I cannot open vim within zsh after I change my default shell to zsh (chsh -s /bin/zsh). Currently, my default shell is bash. If I just use zsh to enter a zsh shell, I have no problems with vim. The problems arise when I try to change my default shell, then open a new terminal window. Any insight would be great as I'd love to be able to play around with zsh.
vim probably lives in a directory that is added to your PATH environment variable in one of your bash start up files. When you start zsh manually, that PATH is inherited by zsh. When you make zsh your default shell, it inherits a PATH which is not modified to include the directory for vim. In bash, type
which vim
to find out which directory vim lives in. Let's say it /usr/other/bin/. Then you would add the following to your .zshenv file (creating it if necessary):
path+=/usr/other/bin
New zsh sessions should now be able to run vim.
I just got oh-my-zsh (a very good command line utility) and would like to utilize this within the PHPStorm terminal. How can I accomplish this?
As oh-my-zsh is more of an extended zsh-configuration, it should be sufficient to just tell PHPStorm to use zsh as Shell. This can be done in the Settings dialog (Menu File->Settings) under section Project Settings->Terminal. Just change Shell Path to the path of zsh (can be found out with type zsh in a terminal).
To affect every (new) project you may have to repeat this in File->Default Settigs
For once and all setup:
Set it in Preferences->Tools->Terminal and Shell Path = /bin/zsh
restart your PhpStorm and thats it.
I have the following lines in my .zshrc
source /etc/profile
source $HOME/.profile
My .profile is not loaded without them, although .profile should be loaded by default in Unix systems.
How can you load .profile without sourcing it at .zshrc?
Look in the Zsh manual where it says to use ~/.zprofile instead of ~/.profile.
In addition to what Martin says about zprofile vs profile, also note that /etc/zprofile and ~/.zprofile are only read when zsh is started as a login shell. If it is "just" an interactive shell, it will only read .zshrc. So the question is how you are starting the zsh. If you use something like Gnome Terminal, you can set in the Profile Preferences that the shell should be started as a login shell.
More info: Z-Shell User's Guide