Various changes

This commit is contained in:
2022-11-30 23:28:40 -08:00
parent ce0a63dc2d
commit 94029ecca4
4 changed files with 42 additions and 58 deletions

View File

@ -49,20 +49,23 @@ alias cd..="cd .."
export LESS="--mouse"
# Safer file functions
#local rm_confirm_flag='-i'
#uname | grep -i linux >/dev/null && rm_confirm_flag='-I'
#alias rm="rm ${rm_confirm_flag}"
function rm() {
echo 'Use trash-put (aliased to "tp") to delete items.'
echo 'If you REALLY want to continue, use "command rm"'
}
alias cp="cp -i"
alias mv="mv -i"
# trash-cli
alias tp='trash-put'
alias tls='trash-list'
alias trs='trash-restore'
if which trash-put >/dev/null 2>&1; then
function rm() {
echo 'Use trash-put (aliased to "tp") to delete items.'
echo 'If you REALLY want to continue, use "command rm"'
}
alias tp='trash-put'
alias tls='trash-list'
alias trs='trash-restore'
else
local rm_confirm_flag='-i'
uname | grep -i linux >/dev/null && rm_confirm_flag='-I'
alias rm="rm ${rm_confirm_flag}"
fi
# Use vi mode
bindkey -v
@ -132,28 +135,21 @@ sudo-command-line() {
fi
}
zle -N sudo-command-line
bindkey "\e\e" sudo-command-line
bindkey -M vicmd '\e\e' sudo-command-line
bindkey -M viins '\e\e' sudo-command-line
bindkey -M vicmd "^f" sudo-command-line
bindkey -M viins "^f" sudo-command-line
# Autosuggestions
load_plugin zsh-autosuggestions
# Fancy prompt (spaceship-prompt)
SPACESHIP_CHAR_SUFFIX=" "
SPACESHIP_VI_MODE_SHOW=false
SPACESHIP_RUST_SYMBOL=" "
SPACESHIP_PACKAGE_SYMBOL=" "
autoload -U promptinit && promptinit
prompt spaceship
# Fancy prompt (starship)
eval "$(starship init zsh)"
# Change cursor shape for different vi modes.
function __zsh_vim_key_prompt_handler {
SPACESHIP_CHAR_SYMBOL=""
local _shape=0
case "${KEYMAP}" in
main) _shape=6; SPACESHIP_CHAR_SYMBOL="" ;; # vi insert: line
viins) _shape=6; SPACESHIP_CHAR_SYMBOL="" ;; # vi insert: line
main) _shape=6 ;; # vi insert: line
viins) _shape=6 ;; # vi insert: line
isearch) _shape=6 ;; # inc search: line
virep) _shape=4 ;; # vi replace: underscore
command) _shape=4 ;; # read a command: underscore
@ -166,39 +162,22 @@ function __zsh_vim_key_prompt_handler {
zle reset-prompt
printf '\e[%d q' "${_shape}"
}
function __zsh_check_disabled_git_prompt_dirs {
local reset_prompt=true
for file in ${(s:\0:)__ZSH_PROMPT_EXCLUDE_GIT_STATUS}; do
if [[ "${PWD:P}/" = "${file}/"* ]]; then
SPACESHIP_GIT_STATUS_SHOW=false
reset_prompt=false
break
fi
done
if "${reset_prompt}"; then
SPACESHIP_GIT_STATUS_SHOW=true
fi
}
function chpwd {
__zsh_check_disabled_git_prompt_dirs
}
function zle-line-init {
__zsh_vim_key_prompt_handler
}
function zle-keymap-select {
__zsh_vim_key_prompt_handler
}
function zle-line-init {
printf '\e[6 q'
}
zle -N zle-keymap-select
zle -N zle-line-init
# Exclude DIR from spaceship's git status module
# prompt_exclude_git_status <dir>
function prompt_exclude_git_status {
__ZSH_PROMPT_EXCLUDE_GIT_STATUS="${__ZSH_PROMPT_EXCLUDE_GIT_STATUS}\0${1:P}"
}
# Fast switch of modes
KEYTIMEOUT=1
# Direnv
eval "$(direnv hook zsh)"
if which direnv >/dev/null 2>&1; then
eval "$(direnv hook zsh)"
fi
# Bookmarks
[ -v ZSH_BOOKMARK_DIR ] || ZSH_BOOKMARK_DIR="${HOME}/.cache/zsh/bookmarks"
@ -251,7 +230,6 @@ setopt histignoredups
# Clean up internal functions
unfunction load_plugin
unfunction prompt_exclude_git_status
# Run fortune and cowsay if we are not in nvim
[[ -v NVIM ]] || fortune | cowsay -felephant-in-snake -n