浏览代码

Add ZSH suggestions and aliases

tancou 4 年之前
父节点
当前提交
c06958d066
共有 4 个文件被更改,包括 42 次插入1 次删除
  1. 20 0
      DOCUMENTATION/content/documentation/index.md
  2. 2 0
      docker-compose.yml
  3. 2 0
      env-example
  4. 18 1
      workspace/Dockerfile

+ 20 - 0
DOCUMENTATION/content/documentation/index.md

@@ -2284,6 +2284,26 @@ For configuration information, visit the [bash-git-prompt repository](https://gi
 
 **Note** You can configure Oh My ZSH by editing the `/home/laradock/.zshrc` in running container.
 
+> With the ZSH autosuggestions plugin.
+
+[ZSH autosuggestions plugin](https://github.com/zsh-users/zsh-autosuggestions) suggests commands as you type based on history and completions.
+
+1 - Enable ZSH as described previously
+
+2 - Set `SHELL_OH_MY_ZSH_AUTOSUGESTIONS` to `true`
+
+3 - Rebuild and use ZSH as described previously
+
+> With bash aliases loaded.
+
+Laradock provides aliases through the `aliases.sh` file located in the `laradock/workspace` directory. You can load it into ZSH.
+
+1 - Enable ZSH as described previously
+
+2 - Set `SHELL_OH_MY_ZSH_ALIASES` to `true`
+
+3 - Rebuild and enjoy aliases
+
 <br>
 <a name="phpstorm-debugging"></a>
 ## PHPStorm Debugging Guide

+ 2 - 0
docker-compose.yml

@@ -63,6 +63,8 @@ services:
         args:
           - CHANGE_SOURCE=${CHANGE_SOURCE}
           - SHELL_OH_MY_ZSH=${SHELL_OH_MY_ZSH}
+          - SHELL_OH_MY_ZSH_AUTOSUGESTIONS=${SHELL_OH_MY_ZSH_AUTOSUGESTIONS}
+          - SHELL_OH_MY_ZSH_ALIASES=${SHELL_OH_MY_ZSH_ALIASES}
           - UBUNTU_SOURCE=${UBUNTU_SOURCE}
           - BASE_IMAGE_TAG_PREFIX=${WORKSPACE_BASE_IMAGE_TAG_PREFIX}
           - LARADOCK_PHP_VERSION=${PHP_VERSION}

+ 2 - 0
env-example

@@ -83,6 +83,8 @@ DOCKER_SYNC_STRATEGY=native_osx
 # If you want to use "Oh My ZSH!" with Laravel autocomplete plugin, set SHELL_OH_MY_ZSH to true.
 
 SHELL_OH_MY_ZSH=false
+SHELL_OH_MY_ZSH_AUTOSUGESTIONS=false
+SHELL_OH_MY_ZSH_ALIASES=false
 
 ###########################################################
 ################ Containers Customization #################

+ 18 - 1
workspace/Dockerfile

@@ -1424,6 +1424,9 @@ RUN if [ ${SHELL_OH_MY_ZSH} = true ]; then \
     apt install -y zsh \
 ;fi
 
+ARG SHELL_OH_MY_ZSH_AUTOSUGESTIONS=false
+ARG SHELL_OH_MY_ZSH_ALIASES=false
+
 USER laradock
 RUN if [ ${SHELL_OH_MY_ZSH} = true ]; then \
     sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh) --keep-zshrc" && \
@@ -1439,7 +1442,21 @@ bindkey "^[[3~" delete-char\n\
 bindkey "^[[4~" end-of-line\n\
 bindkey "^[[5~" up-line-or-history\n\
 bindkey "^[[6~" down-line-or-history\n\
-bindkey "^?" backward-delete-char\n' >> /home/laradock/.zshrc \
+bindkey "^?" backward-delete-char\n' >> /home/laradock/.zshrc && \
+  if [ ${SHELL_OH_MY_ZSH_AUTOSUGESTIONS} = true ]; then \
+    sh -c "git clone https://github.com/zsh-users/zsh-autosuggestions /home/laradock/.oh-my-zsh/custom/plugins/zsh-autosuggestions" && \
+    sed -i 's~plugins=(~plugins=(zsh-autosuggestions ~g' /home/laradock/.zshrc && \
+    sed -i '1iZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20' /home/laradock/.zshrc && \
+    sed -i '1iZSH_AUTOSUGGEST_STRATEGY=(history completion)' /home/laradock/.zshrc && \
+    sed -i '1iZSH_AUTOSUGGEST_USE_ASYNC=1' /home/laradock/.zshrc && \
+    sed -i '1iTERM=xterm-256color' /home/laradock/.zshrc \
+  ;fi && \
+  if [ ${SHELL_OH_MY_ZSH_ALIASES} = true ]; then \
+    echo "" >> /home/laradock/.zshrc && \
+    echo "# Load Custom Aliases" >> /home/laradock/.zshrc && \
+    echo "source /home/laradock/aliases.sh" >> /home/laradock/.zshrc && \
+    echo "" >> /home/laradock/.zshrc \
+  ;fi \
 ;fi
 
 USER root