Search code examples
macosshellaws-cliiterm2

iTerm2 opens command response in vi like window


I have iTerm Build 3.3.9 installed. I have configured oh-my-zsh with following plugins & themes

ZSH_THEME="powerlevel10k/powerlevel10k"

ZSH_DISABLE_COMPFIX="true"
plugins=(aws git colored-man-pages colorize github virtualenv pip python osx zsh-syntax-highlighting zsh-completions zsh-autosuggestions django npm zsh-interactive-cd zsh-navigation-tools)

Now there are 2 issues that i am trying to solve

  1. See the attached image, I have written the command uptil aws cognito-i and remaining is appearing as autosuggestion. the problem is that with my setup (probably theme but i have tried multiple themes) i am unable to distinguish between the command that i have typed and the command is being suggested. normally suggested command should appear a little dimmer but its the same color/opacity as the one that i have written. how to fix this

  2. The second issue is that whenever i run a command with aws cli (also with aws-nuke, the response is opened with a new vi type window, i.e., the commands get removed and i see blank window with each line starting with ~ and at the end of the window it says END. Why is it happening and how to fix this as well


Solution

  • To fix the first issue try moving zsh-syntax-highlighting to the very end of plugins. From zsh-syntax-highlighting FAQ:

    Why must zsh-syntax-highlighting.zsh be sourced at the end of the .zshrc file?

    zsh-syntax-highlighting.zsh wraps ZLE widgets. It must be sourced after all custom widgets have been created (i.e., after all zle -N calls and after running compinit). Widgets created later will work, but will not update the syntax highlighting.

    To fix the second issue add the following at the end of ~/.zshrc:

    # Use `less` as pager in Zsh.
    READNULLCMD=less
    
    # Use `less` as pager in external commands.
    export PAGER=less
    
    # This affects every invocation of `less`.
    #
    #   -i   case-insensitive search unless search string contains uppercase letters
    #   -R   color
    #   -F   exit if there is less than one page of content
    #   -X   keep content on screen after exit
    #   -M   show more info at the bottom prompt line
    #   -x4  tabs are 4 instead of 8
    export LESS=-iRFXMx4