zsh: clean up indentation

This commit is contained in:
Fernando Schauenburg 2024-02-10 12:10:24 +01:00
parent 67ba69c5e3
commit b60f7e345b
3 changed files with 65 additions and 65 deletions

View file

@ -1,49 +1,49 @@
# ls: make `ls` group directories first if supported.
# lsc: force `ls` to use color output (e.g. for piping into `less`).
if command -v exa >/dev/null 2>&1; then
# Prefer exa if installed
alias \
ls="exa --classify --group-directories-first --group --links" \
la="ls --all" \
lt="ls --long --tree --ignore-glob='.git'" \
lta="lt --all" \
lsc="ls --color=always" \
ltc="lt --color=always"
# Prefer exa if installed
alias \
ls="exa --classify --group-directories-first --group --links" \
la="ls --all" \
lt="ls --long --tree --ignore-glob='.git'" \
lta="lt --all" \
lsc="ls --color=always" \
ltc="lt --color=always"
elif ls --group-directories-first --color=auto >/dev/null 2>&1; then
# GNU ls
alias \
ls="ls --classify --human-readable --group-directories-first --color=auto" \
la="ls --almost-all" \
lt="tree --dirsfirst -FI '.git|Spotlight-V100|.fseventsd'" \
lsc="ls --color=always" \
ltc="tree -C --dirsfirst -FI '.git'"
# GNU ls
alias \
ls="ls --classify --human-readable --group-directories-first --color=auto" \
la="ls --almost-all" \
lt="tree --dirsfirst -FI '.git|Spotlight-V100|.fseventsd'" \
lsc="ls --color=always" \
ltc="tree -C --dirsfirst -FI '.git'"
else
# BSD ls (e.g. macOS)
alias \
ls="ls -hF -G" \
la="ls -A" \
lt="tree --dirsfirst -FI '.git|Spotlight-V100|.fseventsd'" \
lsc="/usr/bin/env CLICOLOR_FORCE=1 ls" \
ltc="tree -C --dirsfirst -FI '.git'"
# BSD ls (e.g. macOS)
alias \
ls="ls -hF -G" \
la="ls -A" \
lt="tree --dirsfirst -FI '.git|Spotlight-V100|.fseventsd'" \
lsc="/usr/bin/env CLICOLOR_FORCE=1 ls" \
ltc="tree -C --dirsfirst -FI '.git'"
fi
alias \
ll="ls -l" \
lla="la -l" \
ltl="lt -L"
ll="ls -l" \
lla="la -l" \
ltl="lt -L"
alias \
grep="grep --color=auto" \
egrep="egrep --color=auto" \
fgrep="fgrep --color=auto"
grep="grep --color=auto" \
egrep="egrep --color=auto" \
fgrep="fgrep --color=auto"
alias tmux="tmux -f $XDG_CONFIG_HOME/tmux/tmux.conf"
if command -v nvim >/dev/null 2>&1; then
alias \
v="nvim" \
vi="nvim" \
vim="nvim" \
vimdiff="nvim -d"
alias \
v="nvim" \
vi="nvim" \
vim="nvim" \
vimdiff="nvim -d"
fi

View file

@ -1,18 +1,18 @@
set_cursor_shape() {
local block='\e[1 q' # blinking block
local underline='\e[3 q' # blinking underline, 4 for steady
local bar='\e[5 q' # blinkind bar, 6 for steady
if [[ -n "$ITERM_SESSION_ID" && -z "$TMUX" ]] {
block='\e]1337;CursorShape=0\a'
bar='\e]1337;CursorShape=1\a'
underline='\e]1337;CursorShape=2\a'
}
local block='\e[1 q' # blinking block
local underline='\e[3 q' # blinking underline, 4 for steady
local bar='\e[5 q' # blinkind bar, 6 for steady
if [[ -n "$ITERM_SESSION_ID" && -z "$TMUX" ]] {
block='\e]1337;CursorShape=0\a'
bar='\e]1337;CursorShape=1\a'
underline='\e]1337;CursorShape=2\a'
}
case "$1" in
block) echo -n $block ;;
bar) echo -n $bar ;;
underline) echo -n $underline ;;
esac
case "$1" in
block) echo -n $block ;;
bar) echo -n $bar ;;
underline) echo -n $underline ;;
esac
}
# Start new prompts with bar shaped cursor.
@ -23,10 +23,10 @@ zle -N zle-line-init
# Switch cursor shape depending on editing mode.
zle-keymap-select() {
case $KEYMAP in
vicmd) set_cursor_shape block ;;
viins|main) set_cursor_shape bar ;;
esac
case $KEYMAP in
vicmd) set_cursor_shape block ;;
viins|main) set_cursor_shape bar ;;
esac
}
zle -N zle-keymap-select

View file

@ -169,33 +169,33 @@ render_exec_time() {
# Hook triggered when a command is about to be executed.
prompt_preexec_hook() {
PROMPT_EXEC_START=$EPOCHSECONDS
PROMPT_EXEC_START=$EPOCHSECONDS
}
# Hook triggered right before the prompt is drawn.
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 start=${PROMPT_EXEC_START:-$stop}
PROMPT_EXEC_TIME=$((stop - start))
unset PROMPT_EXEC_START # needed because preexec is not always called
local stop=$EPOCHSECONDS
local start=${PROMPT_EXEC_START:-$stop}
PROMPT_EXEC_TIME=$((stop - start))
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() {
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 VIRTUAL_ENV_DISABLE_PROMPT=1 # we're doing it ourselves
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 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
add-zsh-hook precmd prompt_precmd_hook
add-zsh-hook preexec prompt_preexec_hook
autoload -Uz add-zsh-hook
add-zsh-hook precmd prompt_precmd_hook
add-zsh-hook preexec prompt_preexec_hook
PS1='$(render_prompt)'
PS1='$(render_prompt)'
}
prompt_setup