From 71c416403622aa9beb33b5771721de141363ced1 Mon Sep 17 00:00:00 2001 From: Felix Pankratz Date: Wed, 26 Feb 2020 18:41:09 +0100 Subject: [PATCH] added .zshrc --- .zshrc | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .zshrc diff --git a/.zshrc b/.zshrc new file mode 100644 index 0000000..854aecd --- /dev/null +++ b/.zshrc @@ -0,0 +1,68 @@ +# +# .zshrc - started by panki on 20200226 +# + +autoload -Uz compinit promptinit +compinit +promptinit + +# This will set the default prompt to the fade theme +# prompt fade green + +# Return Code on right prompt +RPS1='[%F{yellow}$?%f]' + +# thanks to slashbeast for these ones +# Fancy cd that can cd into parent directory, if trying to cd into file. +# useful with ^F fuzzy searcher. +cd() { + if (( $+2 )); then + builtin cd "$@" + return 0 + fi + + if [ -f "$1" ]; then + echo "${yellow}cd ${1:h}${NC}" >&2 + builtin cd "${1:h}" + else + builtin cd "${@}" + fi +} + +setup_git_prompt() { + if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then + unset git_prompt + return 0 + fi + + local git_status_dirty git_branch + + if [ "$(git status --untracked-files='no' --porcelain)" ]; then + git_status_dirty='%F{green}*' + else + unset git_status_dirty + fi + + git_branch="$(git symbolic-ref HEAD 2>/dev/null)" + git_branch="${git_branch#refs/heads/}" + + if [ "${#git_branch}" -ge 24 ]; then + git_branch="${git_branch:0:21}..." + fi + + git_branch="${git_branch:-no branch}" + + git_prompt=" %F{blue}[%F{253}${git_branch}${git_status_dirty}%F{blue}]" + +} + +precmd() { + setup_git_prompt +} + +PS1='%F{green}%B%K{green}█▓▒░%F{white}%K{green}%B%n@%m%b%F{green}%K{black}█▓▒░%F{white}%K{black}%B %D{%a %b %d} %D{%I:%M:%S%P} +%}%F{green}%K{black}%B%~/%b%k${git_prompt}%f ' +# aliases +alias grep='grep --colour=auto' +alias ll='ls -alFh' +lt () { ls -lt ${1} | head }