python: add history to pdb

This commit is contained in:
J. Fernando Sánchez
2026-06-10 23:06:27 +02:00
parent 89f9e3d9bc
commit 1035c858fc
2 changed files with 59 additions and 34 deletions

View File

@@ -1,5 +1,13 @@
{ config, pkgs, inputs, ... }:
let
dotfiles = "${config.home.homeDirectory}/git/dotfiles";
createDotLink = name: {
source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/${name}/.config/${name}";
recursive = true;
};
in
{
imports = [
inputs.nix-index-database.homeModules.default
@@ -137,9 +145,6 @@
# I am not sure this is working
home.sessionVariables = {
XDG_BIN_HOME = "${config.home.homeDirectory}/.local/bin";
#This variable is overriden. It does not work
EDITOR = "hx";
#PAGER = "bat";
};
home.sessionPath = [ "$XDG_BIN_HOME" ];
@@ -176,6 +181,10 @@
set fish_greeting
fish_add_path -g $HOME/.local/bin
'';
shellInit = ''
set -gx EDITOR "nvim"
set -gx VISUAL "$EDITOR"
'';
plugins = [
{ name = "grc"; src = pkgs.fishPlugins.grc.src; }
];
@@ -191,6 +200,7 @@
#programs.neovim.enable = true;
programs.neovim = {
enable = true;
defaultEditor = true;
plugins = with pkgs.vimPlugins; [
(nvim-treesitter.withPlugins (p: with p; [
nix
@@ -238,19 +248,16 @@
fonts.fontconfig.enable = true;
xdg.configFile = let
dotfiles = "${config.home.homeDirectory}/git/dotfiles";
createDotLink = name: {
source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/${name}/.config/${name}";
recursive = true;
};
in {
xdg.configFile = {
"git" = createDotLink "git";
"niri" = createDotLink "niri";
"jj" = createDotLink "jj";
"helix" = createDotLink "helix";
"ghostty" = createDotLink "ghostty";
};
home.file = {
".pdbrc" = {
source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/python/.pdbrc";
};
};
}

18
python/.pdbrc Normal file
View File

@@ -0,0 +1,18 @@
# ~/.pdbrc
import atexit
import os
import readline
# Define where the pdb command history will be saved
historyPath = os.path.expanduser("~/.pdb_history")
# Read existing history if it exists
if os.path.exists(historyPath):
readline.read_history_file(historyPath)
# Register a hook to automatically save history when exiting pdb
def save_history(historyPath=historyPath):
import readline
readline.write_history_file(historyPath)
atexit.register(save_history)