Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Zsh: Update prompt, add/fix aliases
  • Loading branch information
alfunx committed Jul 30, 2018
1 parent 69e2837 commit 5bc1a41
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .oh-my-zsh/custom/themes/gruvbox-dark.zsh-theme
@@ -1,4 +1,4 @@
# vim:ft=zsh ts=2 sw=2 sts=2
# vim:ft=zsh ts=4 sw=4 sts=4

### Variables
# Background
Expand Down
2 changes: 1 addition & 1 deletion .oh-my-zsh/custom/themes/gruvbox-light.zsh-theme
@@ -1,4 +1,4 @@
# vim:ft=zsh ts=2 sw=2 sts=2
# vim:ft=zsh ts=4 sw=4 sts=4

### Variables
# Background
Expand Down
47 changes: 14 additions & 33 deletions .oh-my-zsh/custom/themes/powerline.zsh-theme
@@ -1,29 +1,7 @@
# vim:ft=zsh ts=2 sw=2 sts=2
# vim:ft=zsh ts=4 sw=4 sts=4
#
# agnoster's Theme - https://gist.github.com/3712874
# A Powerline-inspired theme for ZSH
#
# # README
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts).
# Make sure you have a recent version: the code points that Powerline
# uses changed in 2012, and older versions will display incorrectly,
# in confusing ways.
#
# In addition, I recommend the
# [Solarized theme](https://github.com/altercation/solarized/) and, if you're
# using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app -
# it has significantly better color fidelity.
#
# # Goals
#
# The aim of this theme is to only show you *relevant* information. Like most
# prompts, it will only show git information when in a git working directory.
# However, it goes a step further: everything from the current user and
# hostname to whether the last call exited with an error to whether background
# jobs are running in this shell will all be displayed automatically when
# appropriate.
# based on: agnoster's Theme - https://gist.github.com/3712874

### Variables (default: Gruvbox)
# Background
Expand Down Expand Up @@ -62,6 +40,8 @@ CURRENT_BG='NONE'

SEGMENT_SEPARATOR=$'\ue0b0' #
# SEGMENT_SEPARATOR=$'\u258c' # ▌
SEGMENT_SEPARATOR2=$'\ue0b1' #
# SEGMENT_SEPARATOR2=$'\u2502' # │
}

# Begin a segment
Expand Down Expand Up @@ -115,21 +95,22 @@ prompt_git() {
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
dirty=$(parse_git_dirty)
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="$(git rev-parse --short HEAD 2> /dev/null)"
if [[ -e "${repo_path}/BISECT_LOG" || -e "${repo_path}/MERGE_HEAD" || -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then
if [[ -e "${repo_path}/BISECT_LOG" || -e "${repo_path}/MERGE_HEAD" || -e "${repo_path}/REBASE_HEAD" || -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" || -e "${repo_path}/CHERRY_PICK_HEAD" ]]; then
prompt_segment "${PROMPT_3_BG}" "${PROMPT_3_FG_ERROR}"
elif [[ -n $dirty ]]; then
prompt_segment "${PROMPT_3_BG}" "${PROMPT_3_FG_DIRTY}"
else
prompt_segment "${PROMPT_3_BG}" "${PROMPT_3_FG_CLEAN}"
fi

if [[ -e "${repo_path}/BISECT_LOG" ]]; then
mode=' <B>'
elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then
mode=' <M>'
elif [[ -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then
mode=' <R>'
fi
[[ -e "${repo_path}/BISECT_LOG" ]] \
&& mode+=" $SEGMENT_SEPARATOR2 B"
[[ -e "${repo_path}/MERGE_HEAD" ]] \
&& mode+=" $SEGMENT_SEPARATOR2 M"
[[ -e "${repo_path}/REBASE_HEAD" || -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]] \
&& mode+=" $SEGMENT_SEPARATOR2 R"
[[ -e "${repo_path}/CHERRY_PICK_HEAD" ]] \
&& mode+=" $SEGMENT_SEPARATOR2 C"

setopt promptsubst
autoload -Uz vcs_info
Expand Down Expand Up @@ -206,7 +187,7 @@ prompt_hg() {

prompt_svn() {
local rev branch
if in_svn; then
if $(in_svn > /dev/null 2>&1); then
rev=$(svn_get_rev_nr)
branch=$(svn_get_branch_name)
PL_BRANCH_CHAR=$'\ue0a0' #
Expand Down
3 changes: 2 additions & 1 deletion .profile
Expand Up @@ -34,7 +34,8 @@ export LESS_TERMCAP_se=$'\e[39;49m'
export LESS_TERMCAP_us=$'\e[4;96m'
export LESS_TERMCAP_ue=$'\e[0m'
export MANROFFOPT='-c'
export LESS='-iMRj.3'
export LESS='-iMRSj.3'
export SYSTEMD_LESS="$LESS"

# # man / less colors (using tput)
# export LESS_TERMCAP_mb=$(tput bold; tput setaf 2)
Expand Down
12 changes: 7 additions & 5 deletions .zsh.d/alias.zsh
Expand Up @@ -11,7 +11,7 @@ alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'
alias .......='cd ../../../../../..'
alias ........='cd ../../../../.././...'
alias ........='cd ../../../../../../..'

# show type,show almost all
alias l='ls -FA'
Expand All @@ -29,6 +29,7 @@ alias lS='ls -1FSsh'
alias lart='ls -1Fcart'
alias lrt='ls -1Fcrt'
alias t='tail -f'
alias wa='watch -ctn 2'

# Suffix commands
alias -g H='| head'
Expand Down Expand Up @@ -61,6 +62,7 @@ alias grep='grep --color=auto --exclude-dir={.git,.svn}'
alias egrep='egrep --color=auto --exclude-dir={.git,.svn}'
alias -g C='| xclip -selection clipboard -rmlastnl'
alias diff='diff --color=auto'
alias journalctl='journalctl -r'

foreground-job() {
fg
Expand Down Expand Up @@ -312,12 +314,12 @@ fdp() {
local dirs=()

get_parent_dirs() {
if [[ -d "${1}" ]]; then
if [[ -d "$1" ]]; then
dirs+=("$1"); else return;
fi
if [[ "${1}" == '/' ]]; then
for _dir in "${dirs[@]}"; do
echo "$_dir";
if [[ "$1" == '/' ]]; then
for d in "${dirs[@]}"; do
echo "$d";
done
else
get_parent_dirs "$(dirname "$1")"
Expand Down
28 changes: 25 additions & 3 deletions .zshrc
Expand Up @@ -90,7 +90,25 @@ bgnotify_formatted() {
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(zsh-syntax-highlighting zsh-completions zsh-autosuggestions command-not-found colorize bgnotify svn)
plugins=(
zsh-syntax-highlighting
zsh-completions
zsh-autosuggestions
command-not-found
colorize
bgnotify
svn
)

# # Native plugins
# plugins=(
# command-not-found
# colorize
# bgnotify
# svn
# )
# source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh

# Remove plugins if in tty
[[ "$TERM" = 'linux' ]] \
Expand Down Expand Up @@ -137,6 +155,7 @@ setopt COMPLETE_ALIASES
setopt HIST_IGNORE_SPACE
setopt NO_AUTO_CD
setopt INTERACTIVE_COMMENTS
setopt PROMPT_SUBST

# No scrolllock
stty -ixon
Expand All @@ -153,8 +172,8 @@ stty -ixon
[[ -f "$ZSH_CONFIG/fzf.zsh" ]] \
&& source "$ZSH_CONFIG/fzf.zsh"

# Vim mode
#[[ -f "$ZSH_CONFIG/vim.zsh" ]] \
# # Vim mode
# [[ -f "$ZSH_CONFIG/vim.zsh" ]] \
# && source "$ZSH_CONFIG/vim.zsh"

# Gruvbox colors fix
Expand Down Expand Up @@ -182,3 +201,6 @@ if [[ "$TERM" == "linux" ]]; then
ZSH_THEME_GIT_PROMPT_DIRTY="%F{167}%B*%b%f"
ZSH_THEME_GIT_PROMPT_CLEAN=""
fi

# # Directly source prompt
# source "$ZSH/custom/themes/gruvbox-dark.zsh-theme"

0 comments on commit 5bc1a41

Please sign in to comment.