Skip to content

Commit 097b463

Browse files
Copilotswissspidygemini-code-assist[bot]Copilot
authored
docs: add Git Bash on Windows section to installing guide (#635)
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Pascal Birchler <pascalb@google.com>
1 parent 3c9e1c8 commit 097b463

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

guides/installing.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,40 @@ Add `c:\wp-cli` to your path:
272272

273273
You can now use WP-CLI from anywhere in Windows command line.
274274

275+
#### Using WP-CLI with Git Bash on Windows
276+
277+
If you use [Git Bash](https://gitforwindows.org/) as your shell on Windows, the `wp.bat` wrapper will not work. Instead, create a file named `wp` (no extension) in `c:\wp-cli` with the following contents:
278+
279+
```
280+
#!/usr/bin/env bash
281+
282+
script_path=$(command -v "$0" 2>/dev/null || printf '%s\n' "$0")
283+
d=${script_path%[/\\]*}
284+
[ "$d" = "$script_path" ] && d=.
285+
dir=$(cd "$d" && pwd)
286+
287+
# See if we are running in Cygwin by checking for cygpath program
288+
if command -v 'cygpath' >/dev/null 2>&1; then
289+
# Cygwin paths start with /cygdrive/ which will break windows PHP,
290+
# so we need to translate the dir path to windows format. However
291+
# we could be using cygwin PHP which does not require this, so we
292+
# test if the path to PHP starts with /cygdrive/ rather than /usr/bin
293+
if [[ $(which php) == /cygdrive/* ]]; then
294+
dir=$(cygpath -m "$dir")
295+
fi
296+
fi
297+
298+
php "${dir}/wp-cli.phar" "$@"
299+
```
300+
301+
Then make the file executable:
302+
303+
```
304+
chmod +x /c/wp-cli/wp
305+
```
306+
307+
You can now use `wp` from Git Bash.
308+
275309
### Installing via .deb package
276310

277311
On Debian or Ubuntu, just download and open one of the .deb packages: <https://github.com/wp-cli/builds/tree/gh-pages/deb>

0 commit comments

Comments
 (0)