I'm just trying to show the current branch of the git repository I'm inside (if available) by using vcs_info. The relevant portion of my .zshrc file is as follows:
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' formats "%F{010}(%b)%f "
precmd() { vcs_info }
setopt prompt_subst
PROMPT="%F{226}%m:%n # %F{214}%1d %F{226}\$%f ${vcs_info_msg_0_}"
I expect:
I load the terminal and start at ~ (the home directory). zsh prompt should read
hostname:username # user $
cd dev/repo takes me into a git repo, zsh prompt should read
hostname:username # repo $ (master)
cd .. takes me back to dev, which isn't a git repo, prompt should read
hostname:username # dev $
I experience:
The prompt never changes / updates automatically; I have to run source ~/.zshrc to make the prompt update as I change directories.
What I have tried:
I've tried updating the precmd() block to be as follows:
precmd() {
vcs_info
echo "This has been executed"
}
And I see This has been executed right before every prompt, so I know that the precmd block is being entered correctly. It seems that the vcs_info just isn't working.
Perhaps I'm missing something; can someone point out what the issue could be? Thanks!
Figured it out by happenstance a few months later after not really caring... the prompt has to use single quotes instead of double-quotes.
PROMPT='%F{226}%m:%n # %F{214}%1d %F{226}\$%f ${vcs_info_msg_0_}'
Putting the whole thing inside the precmd() worked
autoload -Uz vcs_info
precmd() {
vcs_info
# Format the vcs_info_msg_0_ variable
zstyle ":vcs_info:git:*" formats "(%b) "
echo -e -n "\x1b[\x33 q"
PROMPT="%B%1~ $%b %F{004}${vcs_info_msg_0_}%f> "
RPROMPT=" %F{005}%T%f"
}
Related
MacOS Ventura 13.1
M2 Silicon
Trying to set up a new mac. On my existing Mac, I have a .zshrc, and in it, I have the following:
## begin Git branch prompt
git_branch_test_color() {
local ref=$(git symbolic-ref --short HEAD 2> /dev/null)
if [ -n "${ref}" ]; then
if [ -n "$(git status --porcelain)" ]; then
local gitstatuscolor='%F{red}'
else
local gitstatuscolor='%F{green}'
fi
echo "${gitstatuscolor} (${ref})"
else
echo ""
fi
}
setopt PROMPT_SUBST
PROMPT='%/ $(git_branch_test_color)%F{none} $ '
# add 24h time the right side
RPROMPT='%D{%m-%d-%Y %k:%M:%S}'
## end Git branch prompt
And I would get something like:
/Users/jmac/Development/repos/p1 (development) $ 02-16-2023 19:20:56
(development) is in red, because I have not checked in my changes and the full path is there for me to see.
On the new Mac, there is no .zshrc by default, so I added the code to the .zprofile file, and it's not working the same. I see the date/time on the right, but I don't see the full path and the prompt looks like this:
/Users/jmac p1 % 02-16-2023 19:20:56
Any ideas? prompt modification is not my forte.
The short answer: create a ~/.zshrc file and move that code into it.
The slightly longer answer: something is overriding the value in the PROMPT variable. There isn't anything in the default zsh installation that'll turn the $ in your prompt into a %.
That 'something' could be in a few different forms. There may be code that is modifying the PS1 variable, which is essentially a synonym for PROMPT. Or there may be something hidden in scripts or functions called from ~/.zprofile (for example, oh-my-zsh does this, albeit usually from ~/.zshrc).
Some options
Try to trace what's happening in the zprofile file. One way to do that is to run these commands:
setopt xtrace
. ~/.zprofile
The main challenge here is often the sheer volume of the output; it may be difficult to find the spot where the prompt is being set.
Move the PROMPT assignment to the bottom of ~/.zprofile. Then your assignment should override whatever is setting the value earlier in the process.
Move the PROMPT assignment into ~/.zshrc. This is a better place for the assignment anyway, since .zshrc is only loaded for interactive shells, and setting the prompt is only used in interactive shells.
The code in ~/.zshrc is loaded after the code in ~/.zprofile, so this has a similar effect to the prior option.
If none of these options have any effect, then you'll need to look for other startup files, e.g. ~/.zlogin. There's a nice overview of how the various dot files are handled in zsh in this answer.
a simple summary is in the title but to further explain:
Whenever i open my terminal (iterm2) i load into zsh but completions don't seem to work, then when i manually run source .zshrc it does fully load. I've tried moving stuff around in my .zshrc file to see if the order of loading was incorrect but it didn't fix anything.
My .zshrc file:
# ZSH customization
export ZSH="/Users/user/.oh-my-zsh"
source $ZSH/oh-my-zsh.sh
plugins=(git docker asdf zsh-autosuggestions zsh-completions zsh-history-substring-search zsh-syntax-highlighting)
autoload -U compinit && compinit
# color
. "/Users/user/.bin/lscolors.sh" #big color file
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
# alias
alias ip="curl ifconfig.me"
alias ls="gls --color --group-directories-first -hp"
alias ydl="youtube-dl"
alias py="python"
alias code="codium"
# env
export PATH="/usr/local/opt/ncurses/bin:/usr/local/sbin:/usr/local/opt/openssl#1.1/bin:$PATH:/opt/metasploit-framework/bin:$HOME/.bin:$HOME/.cargo/bin"
export EDITOR=/usr/local/bin/codium
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export LDFLAGS="-L/usr/local/opt/openssl#1.1/lib -L/usr/local/opt/ncurses/lib"
export CPPFLAGS="-I/usr/local/opt/openssl#1.1/include -I/usr/local/opt/ncurses/include"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/ncurses/lib/pkgconfig"
# fzf
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# inits
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
eval "$(starship init zsh)"
Any help would be appreciated, if i should provide more info please tell me.
You're making two mistakes in your .zshrc file:
If you do source $ZSH/oh-my-zsh.sh, then you shouldn't also do autoload -U compinit && compinit, because the former includes the latter.
Running compinit more than once can cause problems and slows down your shell’s startup. Each time you run it, it reinitializes the completion system. This will erase any completion entries that were added programmatically (rather than picked up automatically from your $fpath) after the previous compinit was run.
plugins=( ... ) should be done before doing source $ZSH/oh-my-zsh.sh.
$plugins is not special to your shell in any way. Rather, it’s a parameter that’s read by OMZ.
So, change the top of your .zshrc file to this:
ZSH="/Users/user/.oh-my-zsh"
plugins=(
git
docker
asdf
zsh-autosuggestions
zsh-completions
zsh-history-substring-search
zsh-syntax-highlighting
)
source $ZSH/oh-my-zsh.sh
THE ISSUE
I have a .bash_profile with the following settings:
# Git configuration
## Branch name in prompt
source ~/.git-prompt.sh
PS1='[\W$(__git_ps1 " (%s)")]\$ '
export PROMPT_COMMAND='echo -ne "\033]0;${PWD/#$HOME/~}\007"'
These settings output the following prompt:
[my-git-repo(master)]$ ls
index.html
[my-git-repo(master)]$
Not bad. You have the base working directory (\W), branch indication—nice and minimal. However, I want the prompt to look like this because it's easier for me to visually parse large outputs:
[my-git-repo(master)]$ ls
index.html
[my-git-repo(master)]$
MY ATTEMPTED SOLUTION
So, to achieve this, I changed my .bash_profile to:
# Git configuration
## Branch name in prompt with newlines
source ~/.git-prompt.sh
PROMPT_COMMAND='PROMPT_COMMAND='\''PS1="\n[\W$(__git_ps1 " (%s)")]\$ "'\'
export PROMPT_COMMAND='echo -ne "\033]0;${PWD/#$HOME/~}\007"'
However, the new prompt looked like this:
[my-git-repo]$ ls
index.html
[my-git-repo]$
As you can see, there is no newline after ls (my attempts to incorporate it failed), there is a newline after index.html, and the branch indication (master) has disappeared.
So close, yet I'm not entirely sure what I'm doing wrong. Help is appreciated!
You need to make use of PS0 (supported in bash 4.4 or later) to add a blank line after your input. You can also simply add a newline to the beginning of your PS1.
PS0='\n'
PS1='\n[\W$(__git_ps1 " (%s)")]\$ '
Prior to 4.4, you would need to install a complicated DEBUG trap to ensure that it only adds a newline before the first affected command is executed; I'm not going to try to do that correctly.
Recently, I give a try on oh my zsh, everything looks good till I try virtualevn and virtualenvwrapper. When I activate a virtualenv (e.g test), on normal bash, I will see the virtualenv name like:
(test)abc#abc:
But when I switched to zsh, I cannot see virtualenv name. Even though, I alr add virtualenv and virtualenvwrapper in plugins of oh my zsh. I also checked the activate file of my virtualenv, it contains:
f [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then
_OLD_VIRTUAL_PS1="$PS1"
if [ "x" != x ] ; then
PS1="$PS1"
else
PS1="(`basename \"$VIRTUAL_ENV\"`) $PS1"
fi
export PS1
fi
Is it because the comparision ["x" != x] return true?
Updated:
I tried to echo $PS1 in activate file, and got this:
(test) %{$fg[magenta]%}%n%{$reset_color%}%{$fg[cyan]%}#%{$reset_color%}%{$fg[yellow]%}%m%{$reset_color%}%{$fg[red]%}:%{$reset_color%}%{$fg[cyan]%}%0~%{$reset_color%}%{$fg[red]%}|%{$reset_color%}%{$fg[cyan]%}⇒%{$reset_color%}
It seems the $PS1 is correct, but when I echo $PS1 in the terminal, the (test) is gone. It seems the $PS1 is override by something else!
Do this in ~/.zshrc:
plugins=(virtualenv)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status virtualenv)
Caveats:
1 -- add that plugin in addition to other plugins you have.
2 -- I'm using the POWERLEVEL9K theme. Maybe you theme
The best solution is to add the following to the end of your ~/.zshrc file:
export VIRTUAL_ENV_DISABLE_PROMPT=
This will override the value in virtualenv.plugin.zsh - no need to change that file.
My setting to display Python virtualenv name for the default (a.k.a. robbyrussell) theme is the following.
In the .zshrc file
virtualenv added in plugins
Add custom function:
function virtualenv_info {
[ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
}
Navigate to your theme
My theme is the default theme for zsh:
$ vim ~/.oh-my-zsh/themes/robbyrussell.zsh-theme
Add this command right after existing PROMPT commands:
PROMPT+='%{$fg[green]%}$(virtualenv_info)%{$reset_color%}%'
Finally
$ source ~/.zshrc
PS: You can add your name or a few space before or after the PROMPT+.
Hope that helps!
Found the problem, it's due to the theme. The theme I used in the above case is pygmalion, it won't allow u to change $PS1.
After changed to robbyrussell theme, I can change $PS1 in terminal, but still cannot see the virtualenv name. After a while debugging, I found that by default the virtualenv plugin of oh my zsh disable the prompt:
# disables prompt mangling in virtual_env/bin/activate
export VIRTUAL_ENV_DISABLE_PROMPT=1
So just comment out the line in virtualenv plugin, problem solved.
As per this guide here
First add virtualenv dependency under plugin in file .zshrc
If this doesn't work for you, then it means that the theme(one of oh-my-zsh theme) you have selected doesn't include virtualenv name in bash prompt so try second step.
Go to file ~/.oh-my-zsh/themes/YOUR_THEME_NAME.zsh-theme and add this in base prompt
%{$fg[green]%}$(virtualenv_prompt_info)%{$reset_color%}%
NOTE: virtualenv_prompt_info is the name of function which is declared in ~/.oh-my-zsh/plugins/virtualenv/virtualenv.plugin.zsh. If your plugin file have different function name then change it accordingly.
Or you can declare your own function in ~/.zshrc file as shown in this guide
If you are using conda to start your virtual environment the envorionment variable will be different. To figure out the name of the environment that holds your virtaulenv name type printenv and look through the output. For me it is CONDA_PROMPT_MODIFIER
after you know the name of the variable open .zshrc and add this function
function virtualenv_info {
[ $CONDA_PROMPT_MODIFIER ] && echo `basename $CONDA_PROMPT_MODIFIER`
}
and below that add this line
PROMPT="%{$fg[green]%}$(virtualenv_info)%{$reset_color%}%${PROMPT}"
close the editor and type source .zshrc
In the case you installed Anaconda using Homebrew:
brew tap homebrew/cask-versions
brew cask install anaconda
And you are using POWERLEVEL9K theme
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
All you need to do is add this line to the end of .zshrc :
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time anaconda)
There's no need for virtualenv plugin.
Edited:
In case you already had conda installed for bash and you get:
zsh: command not found: conda
Run this:
~/anaconda3/bin/conda init zsh
I made it work following this link: https://askubuntu.com/a/387098
I reproduce the answer below.
How the prompt is changed is defined in the script bin/activate inside the virtual environment directory. This file is created by virtualenv from a template. Unfortunatelly, the only way of prompt modification provided by the template is prepending (env name) or whatever is set with --prompt.
To modify the prompt in the way you want, I'd suggest circumventing the setting of the prompt in bin/activate and modify the definition of PROMPT in your theme file.
First add the following to your.zsh-theme (or .zshrc)
export VIRTUAL_ENV_DISABLE_PROMPT=yes
function virtenv_indicator {
if [[ -z $VIRTUAL_ENV ]] then
psvar[1]=''
else
psvar[1]=${VIRTUAL_ENV##*/}
fi
}
add-zsh-hook precmd virtenv_indicator
and add %(1V.(%1v).) in front of the second line of the definition of PROMPT. It should then look like this:
PROMPT='
%(1V.(%1v).)%{$fg_bold[grey]%}[%{$reset_color%}%{$fg_bold[${host_color}]%}%n#%m%{$reset_color%}%{$fg_bold[grey]%}]%{$reset_color%} %{$fg_bold[blue]%}%10c%{$reset_color%} $(git_prompt_info) $(git_remote_status)
%{$fg_bold[cyan]%}❯%{$reset_color%} '
If you want some color you could add %(1V.%{$fs_bold[yellow]%}(%1v)%{$reset_color%}.) for example.
Explanation:
virtenv_indicator will be called each time before the prompt is created. It checks if $VIRTUAL_ENV is set and not empty. If so, it sets the first element of the $psvar array to $VIRTUAL_ENV with everything before and including the last / removed (like basename $VIRTUAL_ENV but less expensive)
In the definition of PROMPT %(1V.(%1v).) checks if the first element of $psvar is set and not empty (%(1V.true-text.false-text)) and adds the content of the this element plus some parentheses ((%1v))
export VIRTUAL_ENV_DISABLE_PROMPT=yes disables any prompt setting by bin/activate scripts.
if you use zsh and pyenv, put this into ~/.zshrc
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
#export PS1='($(pyenv version-name)) '$PS1
export PYENV_VIRTUALENV_DISABLE_PROMPT=1
export BASE_PROMPT=$PS1
function updatePrompt {
if [[ "$(pyenv version-name)" != "system" ]]; then
# the next line should be double quote; single quote would not work for me
export PS1="($(pyenv version-name)) "$BASE_PROMPT
else
export PS1=$BASE_PROMPT
fi
}
export PROMPT_COMMAND='updatePrompt'
precmd() { eval '$PROMPT_COMMAND' } # this line is necessary for zsh
I am also using Oh My Zsh with the pygmalion theme. I had to edit the pygmalion script to add the virtual environment name before the prompt name.
open ~/.oh-my-zsh/themes/pygmalion.zsh-theme, modify the prompt_pygmalion_precmd function as following:
prompt_pygmalion_precmd(){
setopt localoptions extendedglob
local gitinfo=$(git_prompt_info)
local gitinfo_nocolor=${gitinfo//\%\{[^\}]##\}}
local exp_nocolor="$(print -P \"$base_prompt_nocolor$gitinfo_nocolor$post_prompt_nocolor\")"
local prompt_length=${#exp_nocolor}
local python_venv="($(echo $CONDA_DEFAULT_ENV)) "
PROMPT="${python_venv}${base_prompt}${gitinfo}${post_prompt}"
}
The following steps should solve the problem:
open ~/.p10k.zsh.
If you use only the left prompt, make the following changes:
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
# =========================[ Line #1 ]=========================
os_icon # os identifier
dir # current directory
vcs # git status
# =========================[ Line #2 ]=========================
newline # \n
prompt_char # prompt symbol
virtualenv venv .venv env # show the venv on the second line
)
Add the following line, preferably after you adjust POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV:
typeset -g POWERLEVEL9K_VIRTUALENV_GENERIC_NAMES=()
Save the .p10k.zsh.
Restart the terminal.
Now, when you activate the virtual environment (on macOS source my_venv/bin/activate), then the name of the virtual environment (in my case, my_venv) and the version of Python installed on it (3.9.13) will appear after a beautiful Python symbol. Have a look at the attached screenshot.
I am using oh-my-zsh pygmalion them, and this works for me:
add virtualenv plugin in ~/.zshrc
open ~/.oh-my-zsh/themes/pygmalion.zsh-theme, modify the prompt_pygmalion_precmd function to this:
prompt_pygmalion_precmd(){
setopt localoptions extendedglob
local gitinfo=$(git_prompt_info)
local gitinfo_nocolor=${gitinfo//\%\{[^\}]##\}}
local exp_nocolor="$(print -P \"$base_prompt_nocolor$gitinfo_nocolor$post_prompt_nocolor\")"
local prompt_length=${#exp_nocolor}
local python_venv=$(virtualenv_prompt_info)
PROMPT="${python_venv}${base_prompt}${gitinfo}${post_prompt}"
}
Basically just add $(virtualenv_prompt_info) to your PROMPT to wherever you prefer, here I added it to the very beginning of my PROMPT.
You do not need to create new function, as per documentation - this function is created for you.
https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/virtualenv
But You still need to edit theme file, as mentioned above, just enter correct function name - virtualenv_prompt_info:
PROMPT+='%{$fg[green]%}$(virtualenv_prompt_info)%{$reset_color%}%'
After playing with the surround answers, I found the following to be the best for my use case. This checks the $VIRTUAL_ENV_PROMPT and $VIRTUAL_ENV variables every time you change directories and sets the prompt with the correct venv info.
DEFAULT_PROMPT=$PROMPT
function cd() {
builtin cd "$#"
if [[ -n "$VIRTUAL_ENV_PROMPT" ]] ; then
PROMPT="$VIRTUAL_ENV_PROMPT$DEFAULT_PROMPT"
elif [[ -n "$VIRTUAL_ENV" ]] ; then
PROMPT="(`basename $VIRTUAL_ENV`) $DEFAULT_PROMPT"
else
PROMPT=$DEFAULT_PROMPT
fi
}
export PS1='($(pyenv version-name)) '$PS1
source & link to issue #135 in pyenv-virtualenv repo:
https://github.com/pyenv/pyenv-virtualenv/issues/135#issuecomment-582180662
Back to 2023 : here something that worked for me with the theme .
Search the line for "plugins" and add virtualenv (if you are using this one)
plugins=(git python brew macos colored-man-pages virtualenv vscode)
Now look for the ZSH-Theme and use
ZSH_THEME="pygmalion-virtualenv"
Reload your terminal or kill your Visual Studio code window (reloading the terminal into VS cod didn't display the change for me...)
Using iTerm2 with zsh and it isn't recognizing my aliases. Sometimes I have to work in an IDE and can't just easily vim something and the stupid people thought it a good idea to name their applications like MyReallyLongApplicationName.app and since .html files open by default in browsers, I have to:
open -a MyReallyLongApplicationName.app something.html
I have an alias in my .zshrc like:
alias ide="open -a MyReallyLongApplicationName.app"
But zsh won't recognize my aliases. I tried another one just to see if it was me but none of the aliases I create are recognized. Just get "zsh: command not found: ide" or whatever.
So I'm not sure what I'm doing wrong and I've been searching around all day trying to fix things in zsh and the like. As a note, I'm not a pro at Linux/Unix systems so if you're too technical and vague I probably won't understand what you're telling me.
Thanks!
if you do a very simple alias in zsh, does it work? open your .zshrc file, and add the following line:
alias ls='ls -GpF'
after adding that line, type this line in your Terminal:
source ~/.zshrc
tell us what happens. Also, just for shiggles, make sure you are using single quotes vs. double quotes, I have seen that make a difference in the past on different versions of shells/OS/whatnot.
Add "source ~/.bash_profile" to your ~/.zsh config file.
Put this line:
/source: 'source ~/.bash_profile' into ~/.zshrc
After saving changes in ~/.zshrc file, open a new shell window and execute the command in it.
Sometimes the simple solution is what we need...
Add "source ~/.bash_profile" to your ~/.zshrc config file
echo source ~/.bash_profile >> ~/.zshrc
I needed to manually add the alias to my zsh config file and then run the source command on it.
echo alias this='some command' >> ~/.zshrc
source ~/.zshrc
In my case issue was space b/w aliasName and equalTo. you should have to remove those space.
bad assignment
alias keu = 'k exec -it utils bash'
correct one
alias keu='k exec -it utils bash'
What I did, in this case, was created a separate file to store all my aliases. I found this way to be cleaner and easier maintained.
My aliases file is simply called aliases and within my .zshrc I have the following:
# Linking my aliases file
source ~/foldername/aliases
Make sure the double quotes are actual double quotes and not some other character which looks like double quotes.
I was editing ~/.zsh-aliases in OSX - TextEdit, which, when hitting the double quotes key substituted it for another special double quotes character, which is not what ZSH expects.
After editing the alias file with Sublime and replacing the old double quotes with actual double quotes everything runs just fine.
Hope this helps.
I had all my aliases on ~/.bash_profile, so i added at the last line on ~/.zshrc the following line: . ~/.bash_profile and it worked for me.
You should put alias at the end of ~/.zshrc file.
you can use below command to do that:
echo alias this='some command' >> ~/.zshrc
after that run
source ~/.zshrc
then, open a new terminal and execute the command in it.
I'm using both bash and zsh with one .bashrc, .bash_aliases and .zshrc file.
Put this in you .zshrc to load bash files:
# shortcut to refresh .zshrc
alias refz="source ~/.zshrc"
# Load bash files to zsh
test -f $HOME/.bashrc && . $HOME/.bashrc
test -f $HOME/.bash_aliases && . $HOME/.bash_aliases
If you have many bash aliases and functions you may will have some error messages like:
/proc/self/fd/13:12310: bad option: -t
caused by bash specific lines in.bash_aliases or .bashrc files
You can skip those problematic ones using:
if [ -n "$BASH" ] ;then
lines to ignore by zsh
fi
For example kubectl autocompletion
# To fix error massage .bashrc:16: command not found: shopt
# Check if bash is the current shell, if not, skip it
if [ -n "$BASH" ] ;then
# kubectl and bash completions
if [ -x "$(command -v kubectl)" ]; then
source <(kubectl completion bash)
complete -F __start_kubectl k
fi
if ! shopt -oq posix; then
if [ -f /etc/profile.d/bash_completion.sh ]; then
. /etc/profile.d/bash_completion.sh
fi
fi
fi
# Instead I need to put this line somewhere in my zshrc
# to have kubectl autocompletion replacing the skipped bash one:
plugins=(git git-flow brew history node npm kubectl)
# To fix error message .bash_aliases:4: parse error: condition expected: =
# Change these to this syntax to be used by zhs
# Not compatible with zsh:
if [ $HOSTNAME = "x1" ]; then
# Compatible with bash and zsh:
if [[ $HOSTNAME == "x1" ]]; then
I had a bad alias line that should have been obvious.
There is no error checking in these zsh custom scripts, so you may, like me, waste a couple of precious hours trying to find out why your custom aliases or functions are not loading in iTerm2.
I am using MacOS Ventura 13.1 and iTerm 2 v3.4, zsh 5.8.1.
I reloaded and using . ~/zshrc and followed a lot of the suggestions above.
I finally copied my list of aliases and function to the ~/.zshrc file.
Another ~/.zshrc gave me a bad pattern error.
The fix for my case was as follows.
In line with a Unicode string or something that is escaped and requires ' ' (single quotes), you must use the other quote character (double quotes) to encapsulate the alias sting.
In my case, I had entered.
alias fixitemerrow='printf '\e[?2004l''
The fix for this is:-
alias fixitemerrow=" printf '\e[?2004l' "
Do not add spaces in your alias assignment. This is here just for illustration.
Spaces would also require double encapsulation " ' ' ".
Need to create a profile for .zshrc and register the alias into it. (only if the profile isn't available)
cd ~
touch .zshrc && open .zshrc
add all the alias in .zshrc file
source ~/.zshrc
close and re-open terminal and run the alias.