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
|
path = plugins/zsh-completions
|
||||||
url = https://github.com/zsh-users/zsh-completions.git
|
url = https://github.com/zsh-users/zsh-completions.git
|
||||||
ignore = untracked
|
ignore = untracked
|
||||||
[submodule "spaceship-prompt"]
|
|
||||||
path = plugins/spaceship-prompt
|
|
||||||
url = https://github.com/spaceship-prompt/spaceship-prompt.git
|
|
||||||
ignore = untracked
|
|
||||||
[submodule "fzf-tab"]
|
[submodule "fzf-tab"]
|
||||||
path = plugins/fzf-tab
|
path = plugins/fzf-tab
|
||||||
url = https://github.com/Aloxaf/fzf-tab.git
|
url = https://github.com/Aloxaf/fzf-tab.git
|
||||||
|
19
README.md
19
README.md
@ -2,14 +2,25 @@
|
|||||||
This is my personal zsh configuraton.
|
This is my personal zsh configuraton.
|
||||||
|
|
||||||
### Requirements
|
### Requirements
|
||||||
* [exa](https://github.com/ogham/exa) (optional) - better ls
|
* [starship](https://github.com/starship/starship) - a pretty and fast prompt
|
||||||
* [bat](https://github.com/sharkdp/bat) (optional) - better cat, less, man, etc.
|
* [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
|
### Installation
|
||||||
1. Clone this repo and init the submodules
|
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:
|
2. Create a `.zshrc` and fill it with something like this:
|
||||||
> ZSH_CONFIG_DIR="path/to/this/repo"
|
```zsh
|
||||||
> source "${ZSH_CONFIG_DIR}/init.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):
|
3. Optionally, set some other variables (before the `source` line):
|
||||||
* ZSH_BOOKMARK_DIR: Bookmark directory (default: ~/.cache/zsh/bookmarks)
|
* ZSH_BOOKMARK_DIR: Bookmark directory (default: ~/.cache/zsh/bookmarks)
|
||||||
* ZSH_BOOKMARK_LS: If true, run `ls` after jumping to a bookmark
|
* 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"
|
export LESS="--mouse"
|
||||||
|
|
||||||
# Safer file functions
|
# 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 cp="cp -i"
|
||||||
alias mv="mv -i"
|
alias mv="mv -i"
|
||||||
|
|
||||||
# trash-cli
|
# 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 tp='trash-put'
|
||||||
alias tls='trash-list'
|
alias tls='trash-list'
|
||||||
alias trs='trash-restore'
|
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
|
# Use vi mode
|
||||||
bindkey -v
|
bindkey -v
|
||||||
@ -132,28 +135,21 @@ sudo-command-line() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
zle -N sudo-command-line
|
zle -N sudo-command-line
|
||||||
bindkey "\e\e" sudo-command-line
|
bindkey -M vicmd "^f" sudo-command-line
|
||||||
bindkey -M vicmd '\e\e' sudo-command-line
|
bindkey -M viins "^f" sudo-command-line
|
||||||
bindkey -M viins '\e\e' sudo-command-line
|
|
||||||
|
|
||||||
|
|
||||||
# Autosuggestions
|
# Autosuggestions
|
||||||
load_plugin zsh-autosuggestions
|
load_plugin zsh-autosuggestions
|
||||||
|
|
||||||
# Fancy prompt (spaceship-prompt)
|
# Fancy prompt (starship)
|
||||||
SPACESHIP_CHAR_SUFFIX=" "
|
eval "$(starship init zsh)"
|
||||||
SPACESHIP_VI_MODE_SHOW=false
|
|
||||||
SPACESHIP_RUST_SYMBOL=" "
|
|
||||||
SPACESHIP_PACKAGE_SYMBOL=" "
|
|
||||||
autoload -U promptinit && promptinit
|
|
||||||
prompt spaceship
|
|
||||||
# Change cursor shape for different vi modes.
|
# Change cursor shape for different vi modes.
|
||||||
function __zsh_vim_key_prompt_handler {
|
function __zsh_vim_key_prompt_handler {
|
||||||
SPACESHIP_CHAR_SYMBOL="❮"
|
SPACESHIP_CHAR_SYMBOL="❮"
|
||||||
local _shape=0
|
local _shape=0
|
||||||
case "${KEYMAP}" in
|
case "${KEYMAP}" in
|
||||||
main) _shape=6; SPACESHIP_CHAR_SYMBOL="❯" ;; # vi insert: line
|
main) _shape=6 ;; # vi insert: line
|
||||||
viins) _shape=6; SPACESHIP_CHAR_SYMBOL="❯" ;; # vi insert: line
|
viins) _shape=6 ;; # vi insert: line
|
||||||
isearch) _shape=6 ;; # inc search: line
|
isearch) _shape=6 ;; # inc search: line
|
||||||
virep) _shape=4 ;; # vi replace: underscore
|
virep) _shape=4 ;; # vi replace: underscore
|
||||||
command) _shape=4 ;; # read a command: underscore
|
command) _shape=4 ;; # read a command: underscore
|
||||||
@ -166,39 +162,22 @@ function __zsh_vim_key_prompt_handler {
|
|||||||
zle reset-prompt
|
zle reset-prompt
|
||||||
printf '\e[%d q' "${_shape}"
|
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 {
|
function zle-keymap-select {
|
||||||
__zsh_vim_key_prompt_handler
|
__zsh_vim_key_prompt_handler
|
||||||
}
|
}
|
||||||
|
function zle-line-init {
|
||||||
|
printf '\e[6 q'
|
||||||
|
}
|
||||||
zle -N zle-keymap-select
|
zle -N zle-keymap-select
|
||||||
zle -N zle-line-init
|
zle -N zle-line-init
|
||||||
|
|
||||||
# Exclude DIR from spaceship's git status module
|
# Fast switch of modes
|
||||||
# prompt_exclude_git_status <dir>
|
KEYTIMEOUT=1
|
||||||
function prompt_exclude_git_status {
|
|
||||||
__ZSH_PROMPT_EXCLUDE_GIT_STATUS="${__ZSH_PROMPT_EXCLUDE_GIT_STATUS}\0${1:P}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Direnv
|
# Direnv
|
||||||
|
if which direnv >/dev/null 2>&1; then
|
||||||
eval "$(direnv hook zsh)"
|
eval "$(direnv hook zsh)"
|
||||||
|
fi
|
||||||
|
|
||||||
# Bookmarks
|
# Bookmarks
|
||||||
[ -v ZSH_BOOKMARK_DIR ] || ZSH_BOOKMARK_DIR="${HOME}/.cache/zsh/bookmarks"
|
[ -v ZSH_BOOKMARK_DIR ] || ZSH_BOOKMARK_DIR="${HOME}/.cache/zsh/bookmarks"
|
||||||
@ -251,7 +230,6 @@ setopt histignoredups
|
|||||||
|
|
||||||
# Clean up internal functions
|
# Clean up internal functions
|
||||||
unfunction load_plugin
|
unfunction load_plugin
|
||||||
unfunction prompt_exclude_git_status
|
|
||||||
|
|
||||||
# Run fortune and cowsay if we are not in nvim
|
# Run fortune and cowsay if we are not in nvim
|
||||||
[[ -v NVIM ]] || fortune | cowsay -felephant-in-snake -n
|
[[ -v NVIM ]] || fortune | cowsay -felephant-in-snake -n
|
||||||
|
@ -1 +0,0 @@
|
|||||||
Subproject commit 38cb0593ca9b5a92cee4ada831adaf93573f199d
|
|
Loading…
Reference in New Issue
Block a user