zsh on MacOS saves your terminal history to ~/.zsh_history
If you entered a command that you don’t want to remain in your history, edit the file and delete the lines you don’t want to remain in your history, then save. Exist terminal and reopen.
Articles, notes and random thoughts on Software Development and Technology
zsh on MacOS saves your terminal history to ~/.zsh_history
If you entered a command that you don’t want to remain in your history, edit the file and delete the lines you don’t want to remain in your history, then save. Exist terminal and reopen.
Previous script for setting git branch in bash shell is here.
For zsh, here’s an approach from this gist – add to your ~/.zshrc:
function parse_git_branch() { git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p' } COLOR_DEF=$'\e[0m' COLOR_USR=$'\e[38;5;243m' COLOR_DIR=$'\e[38;5;197m' COLOR_GIT=$'\e[38;5;39m' setopt PROMPT_SUBST export PROMPT='${COLOR_USR}%n ${COLOR_DIR}%~ ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF} $ '
zsh attempts to expand any potential filename wildcard characters (such as ‘*’ and ‘?’) used in a command before executing it. This can lead to the confusing error “zsh: No match found” error. What makes this confusing is if you’re trying to execute a grep or something where you are trying to find or match something, since the error implies your search is not working, whereas the error is about the patterns zsh is attempting to expand in the command string, and not from executing the command itself.
Depending on what you’re trying to do, the easiest workaround is to wrap parameters in quotes or escape characters like ‘*’ and ‘?’.
e.g. for curl, wrap urls in quotes.
From : https://gist.github.com/ankurk91/2efe14650d54d7d09528cea3ed432f6d
#Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^]/d' -e 's/ (.*)/ (\1)/'
}
export PS1="\u@\h \W[\033[32m]\$(parse_git_branch)[\033[00m] $ "
Want to find out more about these escaped codes and ANSI escape sequence color codes, here’s a good reference.