Various changes
This commit is contained in:
parent
ce0a63dc2d
commit
94029ecca4
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -14,10 +14,6 @@
|
||||
path = plugins/zsh-completions
|
||||
url = https://github.com/zsh-users/zsh-completions.git
|
||||
ignore = untracked
|
||||
[submodule "spaceship-prompt"]
|
||||
path = plugins/spaceship-prompt
|
||||
url = https://github.com/spaceship-prompt/spaceship-prompt.git
|
||||
ignore = untracked
|
||||
[submodule "fzf-tab"]
|
||||
path = plugins/fzf-tab
|
||||
url = https://github.com/Aloxaf/fzf-tab.git
|
||||
|
19
README.md
19
README.md
@ -2,14 +2,25 @@
|
||||
This is my personal zsh configuraton.
|
||||
|
||||
### Requirements
|
||||
* [exa](https://github.com/ogham/exa) (optional) - better ls
|
||||
* [bat](https://github.com/sharkdp/bat) (optional) - better cat, less, man, etc.
|
||||
* [starship](https://github.com/starship/starship) - a pretty and fast prompt
|
||||
* [trash-cli](https://github.com/andreafrancia/trash-cli)* - safer rm
|
||||
* [direnv](https://github.com/direnv/direnv)* - runs on cd, safely set enviroment
|
||||
* [exa](https://github.com/ogham/exa)* - better ls
|
||||
* [bat](https://github.com/sharkdp/bat)* - better cat, less, man, etc.
|
||||
|
||||
(* = optional)
|
||||
|
||||
### Installation
|
||||
1. Clone this repo and init the submodules
|
||||
```sh
|
||||
git clone 'https://git.zander.im/Zander671/zsh-config.git'
|
||||
git submodule init && git submodule update
|
||||
```
|
||||
2. Create a `.zshrc` and fill it with something like this:
|
||||
> ZSH_CONFIG_DIR="path/to/this/repo"
|
||||
> source "${ZSH_CONFIG_DIR}/init.zsh}"
|
||||
```zsh
|
||||
ZSH_CONFIG_DIR="path/to/this/repo" # This variable *MUST* be set
|
||||
source "${ZSH_CONFIG_DIR}/init.zsh}"
|
||||
```
|
||||
3. Optionally, set some other variables (before the `source` line):
|
||||
* ZSH_BOOKMARK_DIR: Bookmark directory (default: ~/.cache/zsh/bookmarks)
|
||||
* ZSH_BOOKMARK_LS: If true, run `ls` after jumping to a bookmark
|
||||
|
68
init.zsh
68
init.zsh
@ -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
|
||||
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
|
||||
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
|
||||
|
@ -1 +0,0 @@
|
||||
Subproject commit 38cb0593ca9b5a92cee4ada831adaf93573f199d
|
Loading…
Reference in New Issue
Block a user