diff --git a/README.md b/README.md index 0ba107ccd95f62932b367eded96b417bfb11d092..54566ec835b28a46bc2fd1de463c4da44ecd087d 100644 --- a/README.md +++ b/README.md @@ -20,10 +20,10 @@ This is a theme for ZSH which mainly forks the historical theme used on VIA Cent ## Install for Oh-My-ZSH -In order to use this theme, you have to clone this repository in your Oh-My-ZSH `custom/themes` directory (usually `~/.oh-my-zsh/custom/themes`): +In order to use this theme, you have to clone this repository in your Oh-My-ZSH `custom` directory (usually `~/.oh-my-zsh/custom`): ```shell -git clone https://gitlab.viarezo.fr/ViaRezo/oh-my-viarezo.git $ZSH/custom/themes/oh-my-viarezo +git clone https://gitlab.viarezo.fr/ViaRezo/oh-my-viarezo.git $ZSH/custom ``` You then need to select this theme in your `~/.zshrc` : @@ -32,6 +32,13 @@ You then need to select this theme in your `~/.zshrc` : ZSH_THEME="oh-my-viarezo/viarezo" ``` +To enable the custom plugin, juste add `watch` to the list of plugins in the `~/.zshrc`: + +```shell +plugins=(... watch) +``` + +The plugin will allow you to add `watch` in front of your last command by using `Ctrl+Esc`. ## Customization Time format defaults to `%D{%H:%M}`, but can be overwritten by setting the variable `OHMYVIAREZO_TIME_FORMAT` in your `~/.zshrc`. diff --git a/plugins/watch/watch.plugin.zsh b/plugins/watch/watch.plugin.zsh new file mode 100644 index 0000000000000000000000000000000000000000..17fdcbf6807544ca94d7e133c259b26f8e488a6f --- /dev/null +++ b/plugins/watch/watch.plugin.zsh @@ -0,0 +1,46 @@ +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# watch will be inserted before the command +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Connard <baptiste.gc@student-cs.fr> +# +# ------------------------------------------------------------------------------ + +watch-command-line() { + [[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)" +# if [[ -n $EDITOR && $BUFFER == $EDITOR\ * ]]; then +# if [[ ${#LBUFFER} -le ${#EDITOR} ]]; then +# RBUFFER=" ${BUFFER#$EDITOR }" +# LBUFFER="sudoedit" +# else +# LBUFFER="sudoedit ${LBUFFER#$EDITOR }" +# fi +# elif [[ $BUFFER == sudoedit\ * ]]; then +# if [[ ${#LBUFFER} -le 8 ]]; then +# RBUFFER=" ${BUFFER#sudoedit }" +# LBUFFER="$EDITOR" +# else +# LBUFFER="$EDITOR ${LBUFFER#sudoedit }" +# fi + if [[ $BUFFER == watch\ * ]]; then + if [[ ${#LBUFFER} -le 4 ]]; then + RBUFFER="${BUFFER#watch }" + LBUFFER="" + else + LBUFFER="${LBUFFER#watch }" + fi + else + LBUFFER="watch $LBUFFER" + fi +} +zle -N watch-command-line +# Defined shortcut keys: [Alt] [Esc] +bindkey -M emacs '^\e' watch-command-line +bindkey -M vicmd '^\e' watch-command-line +bindkey -M viins '^\e' watch-command-line diff --git a/functions/prompt_utils.zsh b/themes/oh-my-viarezo/functions/prompt_utils.zsh similarity index 100% rename from functions/prompt_utils.zsh rename to themes/oh-my-viarezo/functions/prompt_utils.zsh diff --git a/functions/utils.zsh b/themes/oh-my-viarezo/functions/utils.zsh similarity index 100% rename from functions/utils.zsh rename to themes/oh-my-viarezo/functions/utils.zsh diff --git a/functions/vcs_themes.zsh b/themes/oh-my-viarezo/functions/vcs_themes.zsh similarity index 100% rename from functions/vcs_themes.zsh rename to themes/oh-my-viarezo/functions/vcs_themes.zsh diff --git a/functions/vcs_utils.zsh b/themes/oh-my-viarezo/functions/vcs_utils.zsh similarity index 100% rename from functions/vcs_utils.zsh rename to themes/oh-my-viarezo/functions/vcs_utils.zsh diff --git a/test/utils.zunit b/themes/oh-my-viarezo/test/utils.zunit similarity index 100% rename from test/utils.zunit rename to themes/oh-my-viarezo/test/utils.zunit diff --git a/viarezo.zsh-theme b/themes/oh-my-viarezo/viarezo.zsh-theme similarity index 100% rename from viarezo.zsh-theme rename to themes/oh-my-viarezo/viarezo.zsh-theme