Skip to content

Commit 3e4c2ca

Browse files
authored
Merge pull request laradock#2712 from tancou/zsh-autosuggestion
Add ZSH suggestions and aliases
2 parents 4f6260d + c06958d commit 3e4c2ca

4 files changed

Lines changed: 42 additions & 1 deletion

File tree

DOCUMENTATION/content/documentation/index.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2284,6 +2284,26 @@ For configuration information, visit the [bash-git-prompt repository](https://gi
22842284

22852285
**Note** You can configure Oh My ZSH by editing the `/home/laradock/.zshrc` in running container.
22862286

2287+
> With the ZSH autosuggestions plugin.
2288+
2289+
[ZSH autosuggestions plugin](https://github.com/zsh-users/zsh-autosuggestions) suggests commands as you type based on history and completions.
2290+
2291+
1 - Enable ZSH as described previously
2292+
2293+
2 - Set `SHELL_OH_MY_ZSH_AUTOSUGESTIONS` to `true`
2294+
2295+
3 - Rebuild and use ZSH as described previously
2296+
2297+
> With bash aliases loaded.
2298+
2299+
Laradock provides aliases through the `aliases.sh` file located in the `laradock/workspace` directory. You can load it into ZSH.
2300+
2301+
1 - Enable ZSH as described previously
2302+
2303+
2 - Set `SHELL_OH_MY_ZSH_ALIASES` to `true`
2304+
2305+
3 - Rebuild and enjoy aliases
2306+
22872307
<br>
22882308
<a name="phpstorm-debugging"></a>
22892309
## PHPStorm Debugging Guide

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ services:
6363
args:
6464
- CHANGE_SOURCE=${CHANGE_SOURCE}
6565
- SHELL_OH_MY_ZSH=${SHELL_OH_MY_ZSH}
66+
- SHELL_OH_MY_ZSH_AUTOSUGESTIONS=${SHELL_OH_MY_ZSH_AUTOSUGESTIONS}
67+
- SHELL_OH_MY_ZSH_ALIASES=${SHELL_OH_MY_ZSH_ALIASES}
6668
- UBUNTU_SOURCE=${UBUNTU_SOURCE}
6769
- BASE_IMAGE_TAG_PREFIX=${WORKSPACE_BASE_IMAGE_TAG_PREFIX}
6870
- LARADOCK_PHP_VERSION=${PHP_VERSION}

env-example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ DOCKER_SYNC_STRATEGY=native_osx
8383
# If you want to use "Oh My ZSH!" with Laravel autocomplete plugin, set SHELL_OH_MY_ZSH to true.
8484

8585
SHELL_OH_MY_ZSH=false
86+
SHELL_OH_MY_ZSH_AUTOSUGESTIONS=false
87+
SHELL_OH_MY_ZSH_ALIASES=false
8688

8789
###########################################################
8890
################ Containers Customization #################

workspace/Dockerfile

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1424,6 +1424,9 @@ RUN if [ ${SHELL_OH_MY_ZSH} = true ]; then \
14241424
apt install -y zsh \
14251425
;fi
14261426

1427+
ARG SHELL_OH_MY_ZSH_AUTOSUGESTIONS=false
1428+
ARG SHELL_OH_MY_ZSH_ALIASES=false
1429+
14271430
USER laradock
14281431
RUN if [ ${SHELL_OH_MY_ZSH} = true ]; then \
14291432
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\
14391442
bindkey "^[[4~" end-of-line\n\
14401443
bindkey "^[[5~" up-line-or-history\n\
14411444
bindkey "^[[6~" down-line-or-history\n\
1442-
bindkey "^?" backward-delete-char\n' >> /home/laradock/.zshrc \
1445+
bindkey "^?" backward-delete-char\n' >> /home/laradock/.zshrc && \
1446+
if [ ${SHELL_OH_MY_ZSH_AUTOSUGESTIONS} = true ]; then \
1447+
sh -c "git clone https://github.com/zsh-users/zsh-autosuggestions /home/laradock/.oh-my-zsh/custom/plugins/zsh-autosuggestions" && \
1448+
sed -i 's~plugins=(~plugins=(zsh-autosuggestions ~g' /home/laradock/.zshrc && \
1449+
sed -i '1iZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20' /home/laradock/.zshrc && \
1450+
sed -i '1iZSH_AUTOSUGGEST_STRATEGY=(history completion)' /home/laradock/.zshrc && \
1451+
sed -i '1iZSH_AUTOSUGGEST_USE_ASYNC=1' /home/laradock/.zshrc && \
1452+
sed -i '1iTERM=xterm-256color' /home/laradock/.zshrc \
1453+
;fi && \
1454+
if [ ${SHELL_OH_MY_ZSH_ALIASES} = true ]; then \
1455+
echo "" >> /home/laradock/.zshrc && \
1456+
echo "# Load Custom Aliases" >> /home/laradock/.zshrc && \
1457+
echo "source /home/laradock/aliases.sh" >> /home/laradock/.zshrc && \
1458+
echo "" >> /home/laradock/.zshrc \
1459+
;fi \
14431460
;fi
14441461

14451462
USER root

0 commit comments

Comments
 (0)