Last active
February 24, 2023 12:56
-
-
Save teshanshanuka/ea1c671b9e60d4fa44e42b7acfbb8fae to your computer and use it in GitHub Desktop.
My zsh config.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set up the prompt | |
# reference: https://www.youtube.com/watch?v=eLEo4OQ-cuQ&ab_channel=LukeSmith | |
# https://gist.github.com/LukeSmithxyz/e62f26e55ea8b0ed41a65912fbebbe52 | |
autoload -U colors && colors | |
# PS1='%(?..%F{red}%?)%f[%B%F{blue}%~%f%b]%F{red}>%f ' | |
# PS1='%(?.%F{green}√.%F{red}?%?)%f[%B%F{blue}%~%f%b]%F{red}>%f ' | |
# History in cache directory: | |
HISTSIZE=10000 | |
SAVEHIST=10000 | |
HISTFILE="$HOME/.cache/.zsh-history" | |
setopt appendhistory | |
setopt histignorealldups | |
# Basic auto/tab complete: | |
autoload -U compinit | |
zstyle ':completion:*' menu select | |
zmodload zsh/complist | |
compinit | |
# _comp_options+=(globdots) # Include hidden files. | |
# Use lf to switch directories and bind it to ctrl-o | |
# lfcd () { | |
# tmp="$(mktemp)" | |
# lf -last-dir-path="$tmp" "$@" | |
# if [ -f "$tmp" ]; then | |
# dir="$(cat "$tmp")" | |
# rm -f "$tmp" | |
# [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" | |
# fi | |
# } | |
# bindkey -s '^o' 'lfcd\n' | |
# Edit line in vim with ctrl-e: | |
autoload edit-command-line; zle -N edit-command-line | |
bindkey '^e' edit-command-line | |
# Colored ls output | |
alias ls='ls --color=auto' | |
alias diff='diff --color=auto' | |
alias grep='grep --color=auto' | |
alias egrep='egrep --color=auto' | |
alias fgrep='fgrep --color=auto' | |
# Syntax highlight for less | |
# sudo apt install source-highlight | |
# `dpkg -L libsource-highlight-common | grep lesspipe` should give you the file location | |
export LESSOPEN="| /usr/share/source-highlight/src-hilite-lesspipe.sh %s" | |
export LESS=' -R ' | |
# Load zsh-syntax-highlighting; should be last. | |
# source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 2>/dev/null | |
# Ask to autocorrect commands | |
#setopt correct | |
#export SPROMPT="Correct %R to %r? [Yes, No, Abort, Edit] " | |
# Ctrl+arrow keys to move fw/bw a word | |
bindkey "^[[1;5C" forward-word | |
bindkey "^[[1;5D" backward-word | |
source ~/.zsh_aliases | |
# git prompt from <https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh> | |
# $curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -O | |
# Configs for git prompt | |
source ~/.zsh/git-prompt.sh | |
export GIT_PS1_SHOWDIRTYSTATE=1 | |
export GIT_PS1_SHOWCOLORHINTS=1 | |
export GIT_PS1_SHOWUNTRACKEDFILES=1 | |
export GIT_PS1_OMITSPARSESTATE=1 | |
setopt PROMPT_SUBST | |
# Might need powerline fonts for the git special character below I am not sure where I got it from | |
# sudo apt install fonts-powerline | |
PS1='%(?.%F{green}.%F{red})•%f[%B%F{blue}%~%f%b]$(__git_ps1 " %%F{green}%%f %s")%F{red}%(!. root#.>)%f ' | |
# To hide stderr from command output (e.g. `find -name "something" NOERR`) | |
alias -g NOERR="2>/dev/null" | |
source ~/.fzf.zsh | |
# Need fd - https://github.com/sharkdp/fd | |
export FZF_DEFAULT_COMMAND='fd -I -E .git/ -E node_modules/ -E .vscode' | |
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" | |
export FZF_ALT_C_COMMAND="fd -I -t d" | |
export PATH="$PATH:$HOME/.local/bin" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment