Skip to content

Commit

Permalink
feat: xdebug command
Browse files Browse the repository at this point in the history
  • Loading branch information
hanoii committed Nov 27, 2024
1 parent 97d5dc6 commit 734d451
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .ddev/addon-metadata/pimp-my-shell/manifest.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: pimp-my-shell
repository: .
version: ""
install_date: "2024-11-26T15:10:58-03:00"
install_date: "2024-11-27T13:07:28-03:00"
project_files:
- web-build/Dockerfile.pimp-my-shell
- homeadditions/.bashrc.d/pimp-my-shell.sh
Expand All @@ -10,6 +10,7 @@ project_files:
- commands/web/gum
- commands/web/lazygit
- commands/host/fish
- homeadditions/.local/bin/xdebug
- homeadditions/.local/share/bash-completion/completions/ahoy
- homeadditions/.local/share/fish/vendor_completions.d/ahoy.fish
- homeadditions/.config/starship.toml
Expand Down
30 changes: 30 additions & 0 deletions .ddev/homeadditions/.local/bin/xdebug
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
#ddev-generated

set -e -o pipefail

enable=0
disable=0
if [ ! -f "/tmp/ddev-pimp-my-shell-xdebug" ]; then
if [ "$DDEV_XDEBUG_ENABLED" == "false" ]; then
enable=1
else
disable=1
fi
else
if [ $(cat /tmp/ddev-pimp-my-shell-xdebug) == "0" ]; then
enable=1
else
disable=1
fi
fi

if [ $enable -eq 1 ]; then
enable_xdebug
echo -n "1" > /tmp/ddev-pimp-my-shell-xdebug
fi

if [ $enable -eq 0 ]; then
disable_xdebug
echo -n "0" > /tmp/ddev-pimp-my-shell-xdebug
fi
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ defaults.
- [Install](#install)
- [Features](#features)
- [Tweaks](#tweaks)
* [Xdebug command inside the container](#xdebug-command-inside-the-container)
* [terminal window title](#terminal-window-title)
* [ls replacement](#ls-replacement)
* [ahoy](#ahoy)
* [starship](#starship)
* [fish](#fish)
* [lazygit](#lazygit)
* [go](#go)
* [ddev `post-import-db` hook](#ddev-post-import-db-hook)
* [DDEV `post-import-db` hook](#ddev-post-import-db-hook)

<!-- tocstop -->

Expand Down Expand Up @@ -65,13 +66,26 @@ ddev get https://github.com/hanoii/ddev-pimp-my-shell/tarball/main

## Tweaks

### Xdebug command inside the container

While you can enable Xdebug by following the [DDEV's guide][ddev-xdebug], I work
a lot inside the container.

I found that you can use DDEV's own `enable_xdebug` and `disable_xdebug` inside
the container but I wanted a shortcut to that so this add-on
[ships a small script](homeadditions/.local/bin/xdebug) that simply toggles
Xdebug state by running `xdebug` inside the container.

[ddev-xdebug]:
https://ddev.readthedocs.io/en/stable/users/debugging-profiling/step-debugging/

### terminal window title

Both for bash and fish, this add-on changes the window terminal with a better
default if working inside the container:

- Adds the ddev project name
- shows that is a ddev project
- Adds the DDEV project name
- shows that is a DDEV project
- includes the current $PWD shortenning it.
- shows the currently running command

Expand Down Expand Up @@ -103,7 +117,7 @@ starship preset nerd-font-symbols
### fish

For tide, it uses the default configuration, if you want to have your own on all
of your ddev projects you can create/edit
of your DDEV projects you can create/edit
`~/.ddev/homeadditions/.config/fish/conf.d/mytide.fish` on the host with
something like the following:

Expand All @@ -129,9 +143,9 @@ startup popups.
Other than adding itself to the path and installing some packages I am unsetting
`GOARCH` and `GOOS` for both `ddev ssh` and `ddev fish` so that are not in
conflict with the container OS as
[they are added by ddev from the host](https://github.com/ddev/ddev/issues/6748).
[they are added by DDEV from the host](https://github.com/ddev/ddev/issues/6748).

### ddev `post-import-db` hook
### DDEV `post-import-db` hook

I generally have import scripts that I ship either from other add-ons or
specific to projects and those scripts usually download the database from within
Expand Down
30 changes: 30 additions & 0 deletions homeadditions/.local/bin/xdebug
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
#ddev-generated

set -e -o pipefail

enable=0
disable=0
if [ ! -f "/tmp/ddev-pimp-my-shell-xdebug" ]; then
if [ "$DDEV_XDEBUG_ENABLED" == "false" ]; then
enable=1
else
disable=1
fi
else
if [ $(cat /tmp/ddev-pimp-my-shell-xdebug) == "0" ]; then
enable=1
else
disable=1
fi
fi

if [ $enable -eq 1 ]; then
enable_xdebug
echo -n "1" > /tmp/ddev-pimp-my-shell-xdebug
fi

if [ $enable -eq 0 ]; then
disable_xdebug
echo -n "0" > /tmp/ddev-pimp-my-shell-xdebug
fi
1 change: 1 addition & 0 deletions install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ project_files:
- commands/web/gum
- commands/web/lazygit
- commands/host/fish
- homeadditions/.local/bin/xdebug
- homeadditions/.local/share/bash-completion/completions/ahoy
- homeadditions/.local/share/fish/vendor_completions.d/ahoy.fish
- homeadditions/.config/starship.toml
Expand Down

0 comments on commit 734d451

Please sign in to comment.