diff --git a/.gitmodules b/.gitmodules index 8eadf16..97b58ce 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/README.md b/README.md index 0f3d213..c82c221 100644 --- a/README.md +++ b/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 diff --git a/init.zsh b/init.zsh index 65daae4..2bec09a 100644 --- a/init.zsh +++ b/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 -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 -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 diff --git a/plugins/spaceship-prompt b/plugins/spaceship-prompt deleted file mode 160000 index 38cb059..0000000 --- a/plugins/spaceship-prompt +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 38cb0593ca9b5a92cee4ada831adaf93573f199d