wp cli – Can’t Connect to MySQL Database using WP CLI and MAMP on a macOS Catalina, using Oh My Zsh

I’m running macOS Catalina and am trying to use WP CLI with MAMP, with iTerm2 and Oh My Zsh as my command line.

However in my localhost directory when I enter wp in the command line, and then press q to exit, I get the following errors:

PHP Notice:  Undefined index: SERVER_NAME in phar:///usr/local/Cellar/wp-cli/2.4.0/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1197) : eval()'d code on line 5  
Notice: Undefined index: SERVER_NAME in phar:///usr/local/Cellar/wp-cli/2.4.0/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1197) : eval()'d code on line 5
PHP Warning:  mysqli_real_connect(): (HY000/2002): No such file or directory in /Users/mattpjennings/Desktop/projects/mj/build/mj.net/wp-includes/wp-db.php on line 1626
Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /Users/mattpjennings/Desktop/projects/mj/build/mj.net/wp-includes/wp-db.php on line 1626

Then when I enter wp plugin list I also get the error below:

Error: Error establishing a database connection.

When I enter wp --info I get:

PHP binary: /usr/local/Cellar/php/7.4.6/bin/php
php.ini used:   /usr/local/etc/php/7.4/php.ini

I already tried adding the line below to ~/.oh-my-zsh/custom/aliases.zsh to change the php or php.ini path when I enter wp --info:

#MAMP Madness export 
PATH=/Applications/MAMP/Library/bin:$PATH 
PHP_VERSION=`ls /Applications/MAMP/bin/php/ | sort -n | tail -1` export 
PATH=/Applications/MAMP/bin/php/${PHP_VERSION}/bin:$PATH

I also tried changing the line below on the wp-config.php file, which didn’t work:

define('DB_HOST', '127.0.0.1:8889');

Any help would be appreciated. I really would like to use WP-CLI locally on my Mac.

Keyboard – assign option shift digits in zsh with bindkey

I run zsh Within tmux in the integrated terminal of Visual Studio Code. I have a Swedish keyboard and I am on a Macbook with macOS 10.15.4 Catalina.

For keys like Meta-F and Meta-D to work in this environment, I need to set the Visual Studio code setting terminal.integrated.macOptionIsMeta to true (see https://github.com/microsoft/vscode/issues/11314)
But when I do that, the following characters stop working @$|(){}. The silent press fails without printing anything.

The keys @$|() start working again when i add this .zshrc

bindkey -s "e2" @   # option-2 maps to the at-sign
bindkey -s "e4" $  # option-4 maps to dollar
bindkey -s "e7" |  # option-7 maps to vertical bar
bindkey -s "e8" (  # option-8 maps to left square bracket
bindkey -s "e9" )  # option-9 maps to right square bracket

(These are normal mappings on a Swedish Mac keyboard, e.g. Option-7 usually prints the vertical bar)

So my remaining problem is how to do backslash, left and right braces, ie. {}, Work in this environment again.

On a Swedish keyboard, the backslash is usually entered by pressing Option-Shift-7. Since Shift-7 is slash (/), I had high hopes:

bindkey -s "e/" \

But that doesn't help.

  • How can i do Option-Shift-7 Print backslash?
  • How can i do Option-Shift-8 print a left brace?
  • How can i do Option-Shift-9 print a right curly bracket?

Terminal – ZSH prompt problem: commands are moved 20 spaces to the right when completed, i.e. H. with the TAB key

In this post https://superuser.com/questions/142099/get-function-into-ps1-zsh it seems to be possible to perform a function inside zsh prompt.

Here's how to use a feature in PROMPT ::

setopt PROMPT_SUBST
slash_color () { dirs | awk -F "/" ' {for (i=1; i<=NF; i++) printf "33(38;5;75m"$i"33(38;5;206m/"} '; }

PS1='%F{13}|%F{green}%n@%F{cyan}%m%F{13}|%f%T%F{13}|$(slash_color)%F{13}|%F{7} '

Under the result:

Enter the image description here

PROBLEM: But now I'm facing another problem: if I'm in a directory, for example the first completion with TAB vim + TAB Move the entire display from vim + TAB about twenty spaces to the right.

Here is a screenshot for illustration:

Enter the image description here

As you can see, right after typing vim te and press TAB Key, the command vim te is shifted to the right (about twenty characters): I don't understand where this shift could come from.

I saw this last post on a similar problem: Zsh moves text if the command prompt is too long

I use zsh-5.8 from MacPorts.

If someone could have an explanation / suggestion / hint, it would be okay to say so.

PS: I suspect using a simple ZSH environment variable could fix this strange behavior.

zsh – Tmux always shows the host name instead of running the application

A strange thing happens. I tried to debug it with no luck for 2 days. There is also nothing relevant in the forums.

I just set up my wife's machine because I have to work remotely. I transferred all of my settings from my own desktop to my wife's laptop so everything works fine. And they do it except for one small thing that I can't figure out why it doesn't work. MX Linux 18.3 is running on my desktop and MX Linux 19.1 is running on my wife's laptop

Construction:

MX Linux 19.1, tmux, zsh, prezto, vim

So the problem now. When I open my terminal under tmux, the status right shows the host name. It's all good. When I open VIM, the status_right window title continues to show the local hostname while my desktop shows that vim is running and the full path of the file opened by vim. The same applies to any other app, e.g. htop. My wife's laptop does not update the right pane_title status while my desktop does. I don't have access to my desktop right now, so I'll just post pictures of what my wife's laptop looks like.

Any ideas?

tmux1

tmux2

tmux3

macos – Zsh moves text if the command prompt is too long

Steps to reproduce:

  1. Resize the terminal to a width of 80 or less to simplify the prompt
    wrap up.

  2. Rename temporarily /etc/zshrc if it affects the result.

  3. Create a really deep folder like

    mkdir -p /tmp/very-deep/directory/very-deep/directory/very-deep/directory/very-deep/directory/very-deep/directory
    
  4. Carry a clean Zsh with you

    /usr/bin/env -i ZDOTDIR=/tmp TERM=xterm-256color /bin/zsh
    
  5. Set the prompt with PROMPT='%~ ',

  6. Change to this folder. The command prompt should wrap.

  7. Try auto-complete. For example, type dir Then press the tab key.

On my machine after the last step the dir has been moved by one character. There was a space between the command prompt and the command before I triggered the completion, which was eliminated by dir move to the left. In other words, before I press Tab, the line ends with directory dirbut the completion does it directorydir, This behavior was similar to bash, which did not wrap ANSI escape code properly [ and ], except that in this case there should be no ANSI escape code in the command prompt.

I tried to remove all possible variables including environment variables, configuration files and terminal emulator. What else can go wrong?

If it matters, I'll use Catalina.

Command line – zsh (brew) and oh-my-zsh: Unsafe completion dependent directories detected (as root user)

When I run sudo -s I get these errors:

(oh-my-zsh) Insecure completion-dependent directories detected:
drwxr-xr-x    19 myusername  MYDOMAINDomain Users     608 Feb 10 07:08 /Users/myusername/.oh-my-zsh
drwxr-xr-x     5 myusername  MYDOMAINDomain Users     160 Feb  4 08:40 /Users/myusername/.oh-my-zsh/custom/plugins
drwxr-xr-x    26 myusername  MYDOMAINDomain Users     832 Feb  4 08:40 /Users/myusername/.oh-my-zsh/custom/plugins/zsh-autosuggestions
drwxr-xr-x    22 myusername  MYDOMAINDomain Users     704 Feb  4 08:40 /Users/myusername/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
drwxr-xr-x   277 myusername  MYDOMAINDomain Users    8864 Jan 13 06:21 /Users/myusername/.oh-my-zsh/plugins
drwxr-xr-x     4 myusername  MYDOMAINDomain Users     128 Jan 13 06:21 /Users/myusername/.oh-my-zsh/plugins/bgnotify
drwxr-xr-x     4 myusername  MYDOMAINDomain Users     128 Jan 13 06:21 /Users/myusername/.oh-my-zsh/plugins/brew
drwxr-xr-x     4 myusername  MYDOMAINDomain Users     128 Jan 13 06:21 /Users/myusername/.oh-my-zsh/plugins/git
drwxr-xr-x     5 myusername  MYDOMAINDomain Users     160 Jan 13 06:21 /Users/myusername/.oh-my-zsh/plugins/osx
drwxr-xr-x     4 myusername  MYDOMAINDomain Users     128 Jan 13 06:21 /Users/myusername/.oh-my-zsh/plugins/web-search
drwxr-xr-x     6 myusername  MYDOMAINDomain Users     192 Feb  3  2019 /usr/local/Cellar/zsh/5.7.1/share/zsh
drwxr-xr-x  1148 myusername  MYDOMAINDomain Users   36736 Feb  4 13:06 /usr/local/Cellar/zsh/5.7.1/share/zsh/functions
-rw-r--r--     1 myusername  MYDOMAINDomain Users     279 Feb  3  2019 /usr/local/Cellar/zsh/5.7.1/share/zsh/functions/_SUSEconfig
-rw-r--r--     1 myusername  MYDOMAINDomain Users    2800 Feb  3  2019 /usr/local/Cellar/zsh/5.7.1/share/zsh/functions/_a2ps
-rw-r--r--     1 myusername  MYDOMAINDomain Users     490 Feb  3  2019 
(...)
    -rw-r--r--     1 myusername  MYDOMAINDomain Users     371 Feb  3  2019 /usr/local/Cellar/zsh/5.7.1/share/zsh/functions/_mkzsh
    -rw-r--r--     1 myusername  MYDOMAINDomain Users    5478 Feb  3  2019 /usr/local/Cellar/zsh/5.7.1/share/zsh/functions/_module
    -rw-r--r--     1 myusername  MYDOMAINDomain Users    2095 Feb  3  2019 /usr/local/Cellar/zsh/5.7.1/share/zsh/functions/_module-assistant
    -rw-r--r--     1 myusername  MYDOMAINDomain Users     306 Feb  3  2019 /usr/local/Cellar/zsh/5.7.1/share/zsh/functions/_module_math_func
    -rw-r--r--     1 myusername  MYDOMAINDomain Users    5020 Feb  3  2019 /usr/local/Cellar/zsh/5.7.1/share/zsh/functions/_modutils
    -rw-r--r--     1 myusername  MYDOMAINDomain Users    2001 Feb  3  2019 /usr/local/Cellar/zsh/5.7.1/share/zsh/functions/_mondo
    -rw-r--r--     1 myusername  MYDOMAINDomain Users    2376 Feb  3  2019 /usr/local/Cellar/zsh/5.7.1/share/zsh/functions/_monotone
(...)
    -rw-r--r--     1 myusername  MYDOMAINDomain Users    4061 Feb  3  2019 /usr/local/Cellar/zsh/5.7.1/share/zsh/functions/_zoneadm
    -rw-r--r--     1 myusername  MYDOMAINDomain Users     256 Feb  3  2019 /usr/local/Cellar/zsh/5.7.1/share/zsh/functions/_zones
    -rw-r--r--     1 myusername  MYDOMAINDomain Users    9492 Feb  3  2019 /usr/local/Cellar/zsh/5.7.1/share/zsh/functions/_zpool
    -rw-r--r--     1 myusername  MYDOMAINDomain Users    2084 Feb  3  2019 /usr/local/Cellar/zsh/5.7.1/share/zsh/functions/_zpty
    -rw-r--r--     1 myusername  MYDOMAINDomain Users     696 Feb  3  2019 /usr/local/Cellar/zsh/5.7.1/share/zsh/functions/_zsh
    -rw-r--r--     1 myusername  MYDOMAINDomain Users     719 Feb  3  2019 /usr/local/Cellar/zsh/5.7.1/share/zsh/functions/_zsh-mime-handler
    -rw-r--r--     1 myusername  MYDOMAINDomain Users     384 Feb  3  2019 /usr/local/Cellar/zsh/5.7.1/share/zsh/functions/_zsocket
    -rw-r--r--     1 myusername  MYDOMAINDomain Users   19508 Feb  3  2019 /usr/local/Cellar/zsh/5.7.1/share/zsh/functions/_zstyle
    -rw-r--r--     1 myusername  MYDOMAINDomain Users     586 Feb  3  2019 /usr/local/Cellar/zsh/5.7.1/share/zsh/functions/_ztodo
    -rw-r--r--     1 myusername  MYDOMAINDomain Users    6093 Feb  3  2019 /usr/local/Cellar/zsh/5.7.1/share/zsh/functions/_zypper
    drwxr-xr-x     7 myusername  admin                     224 Feb  4 13:06 /usr/local/share/zsh
    drwxr-xr-x    10 myusername  admin                     320 Feb 10 10:07 /usr/local/share/zsh/site-functions
    lrwxr-xr-x     1 myusername  admin                      39 Sep 30  2016 /usr/local/share/zsh/site-functions/_brew -> ../../../Homebrew/completions/zsh/_brew
    lrwxr-xr-x     1 myusername  admin                      44 Sep 30  2016 /usr/local/share/zsh/site-functions/_brew_cask -> ../../../Homebrew/completions/zsh/_brew_cask
    lrwxr-xr-x     1 myusername  admin                      88 Mar  9  2017 /usr/local/share/zsh/site-functions/_brew_services -> ../../../Homebrew/Library/Taps/homebrew/homebrew-services/completions/zsh/_brew_services
    lrwxr-xr-x     1 myusername  admin                      58 Jan 30 12:15 /usr/local/share/zsh/site-functions/_git -> ../../../Cellar/git/2.25.0_1/share/zsh/site-functions/_git
    lrwxr-xr-x     1 myusername  admin                      71 Jan 27 07:20 /usr/local/share/zsh/site-functions/_kubectl -> ../../../Cellar/kubernetes-cli/1.17.2/share/zsh/site-functions/_kubectl
    lrwxr-xr-x     1 myusername  admin                      63 Feb 10 10:07 /usr/local/share/zsh/site-functions/_kubectx -> ../../../Cellar/kubectx/0.7.1/share/zsh/site-functions/_kubectx
    lrwxr-xr-x     1 myusername  admin                      62 Feb 10 10:07 /usr/local/share/zsh/site-functions/_kubens -> ../../../Cellar/kubectx/0.7.1/share/zsh/site-functions/_kubens

    (oh-my-zsh) For safety, we will not load completions from these directories until
    (oh-my-zsh) you fix their permissions and ownership and restart zsh.
    (oh-my-zsh) See the above list for directories with group or other writability.

    (oh-my-zsh) To fix your permissions you can do so by disabling
    (oh-my-zsh) the write permission of "group" and "others" and making sure that the
    (oh-my-zsh) owner of these directories is either root or your current user.
    (oh-my-zsh) The following command may help:
    (oh-my-zsh)     compaudit | xargs chmod g-w,o-w

    (oh-my-zsh) If the above didn't help or you want to skip the verification of
    (oh-my-zsh) insecure directories you can set the variable ZSH_DISABLE_COMPFIX to
    (oh-my-zsh) "true" before oh-my-zsh is sourced in your zshrc file.

I tried these fixes (from stack overflow and GitHub problems) and tested with a restart of iTerm:

chmod 755 /usr/local/share/zsh
chmod 755 /usr/local/share/zsh/site-functions
chmod -R 755 ~/.oh-my-zsh
chown -R $(whoami) /usr/local/share/zsh
compaudit | xargs chmod g-w,o-w

They all didn't work. Still the same error messages.

Any other idea?
Is it safe to add? (( $UID = 0 )) && ZSH_DISABLE_COMPFIX=true in ZSH rc?
I use brew's zsh as login shell and use the latest oh-my-zsh and macOS Catalina.

ruby – Deployment error since the Catalina update – zsh: / usr / local / bin / cap: wrong interpreter … no such file or directory

Since the Catalina update, I have had some issues deploying all of my websites.
This is the first edition.

If I want to move my local site to uat (staging), I start cap uat deploy branch=release/4.0.0 and it usually runs (before the update) and pushes all my changes to my UAT site.

Instead, I get the following error, and no matter what I try, I can't seem to get rid of it:

zsh: /usr/local/bin/cap: bad interpreter: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: no such file or directory

I've spent far too long trying to figure this out and I couldn't really start with a guide.
If anyone can help, I would be so grateful!