zsh: clean up indentation
This commit is contained in:
parent
67ba69c5e3
commit
b60f7e345b
3 changed files with 65 additions and 65 deletions
|
@ -1,49 +1,49 @@
|
||||||
# ls: make `ls` group directories first if supported.
|
# ls: make `ls` group directories first if supported.
|
||||||
# lsc: force `ls` to use color output (e.g. for piping into `less`).
|
# lsc: force `ls` to use color output (e.g. for piping into `less`).
|
||||||
if command -v exa >/dev/null 2>&1; then
|
if command -v exa >/dev/null 2>&1; then
|
||||||
# Prefer exa if installed
|
# Prefer exa if installed
|
||||||
alias \
|
alias \
|
||||||
ls="exa --classify --group-directories-first --group --links" \
|
ls="exa --classify --group-directories-first --group --links" \
|
||||||
la="ls --all" \
|
la="ls --all" \
|
||||||
lt="ls --long --tree --ignore-glob='.git'" \
|
lt="ls --long --tree --ignore-glob='.git'" \
|
||||||
lta="lt --all" \
|
lta="lt --all" \
|
||||||
lsc="ls --color=always" \
|
lsc="ls --color=always" \
|
||||||
ltc="lt --color=always"
|
ltc="lt --color=always"
|
||||||
elif ls --group-directories-first --color=auto >/dev/null 2>&1; then
|
elif ls --group-directories-first --color=auto >/dev/null 2>&1; then
|
||||||
# GNU ls
|
# GNU ls
|
||||||
alias \
|
alias \
|
||||||
ls="ls --classify --human-readable --group-directories-first --color=auto" \
|
ls="ls --classify --human-readable --group-directories-first --color=auto" \
|
||||||
la="ls --almost-all" \
|
la="ls --almost-all" \
|
||||||
lt="tree --dirsfirst -FI '.git|Spotlight-V100|.fseventsd'" \
|
lt="tree --dirsfirst -FI '.git|Spotlight-V100|.fseventsd'" \
|
||||||
lsc="ls --color=always" \
|
lsc="ls --color=always" \
|
||||||
ltc="tree -C --dirsfirst -FI '.git'"
|
ltc="tree -C --dirsfirst -FI '.git'"
|
||||||
else
|
else
|
||||||
# BSD ls (e.g. macOS)
|
# BSD ls (e.g. macOS)
|
||||||
alias \
|
alias \
|
||||||
ls="ls -hF -G" \
|
ls="ls -hF -G" \
|
||||||
la="ls -A" \
|
la="ls -A" \
|
||||||
lt="tree --dirsfirst -FI '.git|Spotlight-V100|.fseventsd'" \
|
lt="tree --dirsfirst -FI '.git|Spotlight-V100|.fseventsd'" \
|
||||||
lsc="/usr/bin/env CLICOLOR_FORCE=1 ls" \
|
lsc="/usr/bin/env CLICOLOR_FORCE=1 ls" \
|
||||||
ltc="tree -C --dirsfirst -FI '.git'"
|
ltc="tree -C --dirsfirst -FI '.git'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
alias \
|
alias \
|
||||||
ll="ls -l" \
|
ll="ls -l" \
|
||||||
lla="la -l" \
|
lla="la -l" \
|
||||||
ltl="lt -L"
|
ltl="lt -L"
|
||||||
|
|
||||||
alias \
|
alias \
|
||||||
grep="grep --color=auto" \
|
grep="grep --color=auto" \
|
||||||
egrep="egrep --color=auto" \
|
egrep="egrep --color=auto" \
|
||||||
fgrep="fgrep --color=auto"
|
fgrep="fgrep --color=auto"
|
||||||
|
|
||||||
alias tmux="tmux -f $XDG_CONFIG_HOME/tmux/tmux.conf"
|
alias tmux="tmux -f $XDG_CONFIG_HOME/tmux/tmux.conf"
|
||||||
|
|
||||||
if command -v nvim >/dev/null 2>&1; then
|
if command -v nvim >/dev/null 2>&1; then
|
||||||
alias \
|
alias \
|
||||||
v="nvim" \
|
v="nvim" \
|
||||||
vi="nvim" \
|
vi="nvim" \
|
||||||
vim="nvim" \
|
vim="nvim" \
|
||||||
vimdiff="nvim -d"
|
vimdiff="nvim -d"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
set_cursor_shape() {
|
set_cursor_shape() {
|
||||||
local block='\e[1 q' # blinking block
|
local block='\e[1 q' # blinking block
|
||||||
local underline='\e[3 q' # blinking underline, 4 for steady
|
local underline='\e[3 q' # blinking underline, 4 for steady
|
||||||
local bar='\e[5 q' # blinkind bar, 6 for steady
|
local bar='\e[5 q' # blinkind bar, 6 for steady
|
||||||
if [[ -n "$ITERM_SESSION_ID" && -z "$TMUX" ]] {
|
if [[ -n "$ITERM_SESSION_ID" && -z "$TMUX" ]] {
|
||||||
block='\e]1337;CursorShape=0\a'
|
block='\e]1337;CursorShape=0\a'
|
||||||
bar='\e]1337;CursorShape=1\a'
|
bar='\e]1337;CursorShape=1\a'
|
||||||
underline='\e]1337;CursorShape=2\a'
|
underline='\e]1337;CursorShape=2\a'
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
block) echo -n $block ;;
|
block) echo -n $block ;;
|
||||||
bar) echo -n $bar ;;
|
bar) echo -n $bar ;;
|
||||||
underline) echo -n $underline ;;
|
underline) echo -n $underline ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# Start new prompts with bar shaped cursor.
|
# Start new prompts with bar shaped cursor.
|
||||||
|
@ -23,10 +23,10 @@ zle -N zle-line-init
|
||||||
|
|
||||||
# Switch cursor shape depending on editing mode.
|
# Switch cursor shape depending on editing mode.
|
||||||
zle-keymap-select() {
|
zle-keymap-select() {
|
||||||
case $KEYMAP in
|
case $KEYMAP in
|
||||||
vicmd) set_cursor_shape block ;;
|
vicmd) set_cursor_shape block ;;
|
||||||
viins|main) set_cursor_shape bar ;;
|
viins|main) set_cursor_shape bar ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
zle -N zle-keymap-select
|
zle -N zle-keymap-select
|
||||||
|
|
||||||
|
|
|
@ -169,33 +169,33 @@ render_exec_time() {
|
||||||
|
|
||||||
# Hook triggered when a command is about to be executed.
|
# Hook triggered when a command is about to be executed.
|
||||||
prompt_preexec_hook() {
|
prompt_preexec_hook() {
|
||||||
PROMPT_EXEC_START=$EPOCHSECONDS
|
PROMPT_EXEC_START=$EPOCHSECONDS
|
||||||
}
|
}
|
||||||
|
|
||||||
# Hook triggered right before the prompt is drawn.
|
# Hook triggered right before the prompt is drawn.
|
||||||
prompt_precmd_hook() {
|
prompt_precmd_hook() {
|
||||||
PROMPT_EXIT_CODE=$? # this needs to be captured before anything else runs
|
PROMPT_EXIT_CODE=$? # this needs to be captured before anything else runs
|
||||||
|
|
||||||
local stop=$EPOCHSECONDS
|
local stop=$EPOCHSECONDS
|
||||||
local start=${PROMPT_EXEC_START:-$stop}
|
local start=${PROMPT_EXEC_START:-$stop}
|
||||||
PROMPT_EXEC_TIME=$((stop - start))
|
PROMPT_EXEC_TIME=$((stop - start))
|
||||||
unset PROMPT_EXEC_START # needed because preexec is not always called
|
unset PROMPT_EXEC_START # needed because preexec is not always called
|
||||||
|
|
||||||
local job_count='%j'; PROMPT_JOB_COUNT=${(%)job_count}
|
local job_count='%j'; PROMPT_JOB_COUNT=${(%)job_count}
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt_setup() {
|
prompt_setup() {
|
||||||
setopt NO_PROMPT_BANG PROMPT_CR PROMPT_PERCENT PROMPT_SP PROMPT_SUBST
|
setopt NO_PROMPT_BANG PROMPT_CR PROMPT_PERCENT PROMPT_SP PROMPT_SUBST
|
||||||
export PROMPT_EOL_MARK='' # don't show % when a partial line is preserved
|
export PROMPT_EOL_MARK='' # don't show % when a partial line is preserved
|
||||||
export VIRTUAL_ENV_DISABLE_PROMPT=1 # we're doing it ourselves
|
export VIRTUAL_ENV_DISABLE_PROMPT=1 # we're doing it ourselves
|
||||||
|
|
||||||
zmodload zsh/datetime # so that $EPOCHSECONDS is available
|
zmodload zsh/datetime # so that $EPOCHSECONDS is available
|
||||||
|
|
||||||
autoload -Uz add-zsh-hook
|
autoload -Uz add-zsh-hook
|
||||||
add-zsh-hook precmd prompt_precmd_hook
|
add-zsh-hook precmd prompt_precmd_hook
|
||||||
add-zsh-hook preexec prompt_preexec_hook
|
add-zsh-hook preexec prompt_preexec_hook
|
||||||
|
|
||||||
PS1='$(render_prompt)'
|
PS1='$(render_prompt)'
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt_setup
|
prompt_setup
|
||||||
|
|
Loading…
Add table
Reference in a new issue