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, ... }: { 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 = [ imports = [
inputs.nix-index-database.homeModules.default inputs.nix-index-database.homeModules.default
@@ -137,9 +145,6 @@
# I am not sure this is working # I am not sure this is working
home.sessionVariables = { home.sessionVariables = {
XDG_BIN_HOME = "${config.home.homeDirectory}/.local/bin"; 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" ]; home.sessionPath = [ "$XDG_BIN_HOME" ];
@@ -176,6 +181,10 @@
set fish_greeting set fish_greeting
fish_add_path -g $HOME/.local/bin fish_add_path -g $HOME/.local/bin
''; '';
shellInit = ''
set -gx EDITOR "nvim"
set -gx VISUAL "$EDITOR"
'';
plugins = [ plugins = [
{ name = "grc"; src = pkgs.fishPlugins.grc.src; } { name = "grc"; src = pkgs.fishPlugins.grc.src; }
]; ];
@@ -190,30 +199,31 @@
#programs.neovim.enable = true; #programs.neovim.enable = true;
programs.neovim = { programs.neovim = {
enable = true; enable = true;
plugins = with pkgs.vimPlugins; [ defaultEditor = true;
(nvim-treesitter.withPlugins (p: with p; [ plugins = with pkgs.vimPlugins; [
nix (nvim-treesitter.withPlugins (p: with p; [
lua nix
markdown lua
])) markdown
]; ]))
];
extraLuaConfig = '' extraLuaConfig = ''
vim.opt.foldmethod = "expr" vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()" vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()"
vim.opt.foldlevel = 99 vim.opt.foldlevel = 99
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
pattern = "*", pattern = "*",
callback = function() callback = function()
local has_highlighter = vim.api.nvim_buf_line_count(0) > 0 and pcall(vim.treesitter.get_parser) local has_highlighter = vim.api.nvim_buf_line_count(0) > 0 and pcall(vim.treesitter.get_parser)
if not has_highlighter then if not has_highlighter then
vim.wo.foldmethod = "indent" vim.wo.foldmethod = "indent"
end end
end, end,
}) })
''; '';
}; };
#programs.neovim.defaultEditor = false; #programs.neovim.defaultEditor = false;
#programs.helix.enable = true; #programs.helix.enable = true;
@@ -238,19 +248,16 @@
fonts.fontconfig.enable = true; fonts.fontconfig.enable = true;
xdg.configFile = let xdg.configFile = {
dotfiles = "${config.home.homeDirectory}/git/dotfiles";
createDotLink = name: {
source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/${name}/.config/${name}";
recursive = true;
};
in {
"git" = createDotLink "git"; "git" = createDotLink "git";
"niri" = createDotLink "niri"; "niri" = createDotLink "niri";
"jj" = createDotLink "jj"; "jj" = createDotLink "jj";
"helix" = createDotLink "helix"; "helix" = createDotLink "helix";
"ghostty" = createDotLink "ghostty"; "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)