From 2d3e7775de442402b1688a49f267b556a53edb0d Mon Sep 17 00:00:00 2001 From: Arthur <110528300+c0rydoras@users.noreply.github.com> Date: Fri, 5 Dec 2025 21:49:19 +0100 Subject: [PATCH] fix: also look in $XDG_CONFIG_HOME (defaults to ~/.config) for gdbinit (#3462) --- pwndbg/dbg/gdb/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pwndbg/dbg/gdb/__init__.py b/pwndbg/dbg/gdb/__init__.py index e67036976..4919290ae 100644 --- a/pwndbg/dbg/gdb/__init__.py +++ b/pwndbg/dbg/gdb/__init__.py @@ -4,6 +4,7 @@ import re from asyncio import CancelledError from contextlib import contextmanager from contextlib import nullcontext +from os import environ from pathlib import Path from typing import Any from typing import Coroutine @@ -1384,7 +1385,10 @@ class GDB(pwndbg.dbg_mod.Debugger): if disable_any: return - home_file = Path("~/.gdbinit").expanduser().resolve() + config_home = environ.get("XDG_CONFIG_HOME", Path("~/.config").expanduser().resolve()) + home_file = (Path(config_home) / "gdb" / "gdbinit").resolve() + if not home_file.exists(): + home_file = Path("~/.gdbinit").expanduser().resolve() local_file = Path("./.gdbinit").resolve() def load_source(file_path: str): @@ -1395,7 +1399,7 @@ class GDB(pwndbg.dbg_mod.Debugger): is_home_loaded = False if not disable_home and home_file.exists(): - load_source("~/.gdbinit") + load_source(str(home_file)) is_home_loaded = True disable_local = not gdb.parameter("auto-load local-gdbinit")