You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将xonsh历史记录迁移至新电脑?(对比bash操作)

Migrating Xonsh Command History Between Computers

Unlike bash where you just copy .bash_history, xonsh stores its history in a structured format (usually JSON by default), but the process is still simple once you know which files to move. Here's how to do it step by step:

Step 1: Locate Your Xonsh History File(s)

First, on your old computer, open a xonsh shell and run this command to find the primary history file path:

history file

This will output the full path to your history storage (e.g., ~/.local/share/xonsh/xonsh-history.json for the default JSON backend).

If you're using a different history backend (like SQLite), check your backend type first with:

echo $HISTORY_BACKEND

The history file command will still point to the correct file for your active backend (e.g., xonsh-history.sqlite for SQLite).

Step 2: Copy the History File to the New Computer

  • On your old machine, copy the file from the path you found to your new computer (use a USB drive, scp, cloud storage, etc.).
  • On the new computer, place the copied file into the same directory path. If the directory doesn't exist (e.g., if you haven't run xonsh yet), create it first:
    mkdir -p ~/.local/share/xonsh/
    

Step 3: Verify the Migration

Launch xonsh on your new computer and test if your history is available:

  • Run history to see the full list of past commands.
  • Use history search <your-command-keyword> to look for specific entries you know were on the old machine.

Key Notes

  • Permissions: Make sure the copied file has the correct ownership (match your new user account) so xonsh can read/write to it. Use chown if needed:
    sudo chown $USER:$USER ~/.local/share/xonsh/xonsh-history.json
    
  • Version Compatibility: If you're migrating between significantly different xonsh versions, there's a small chance the history file format might have changed. In most cases, though, xonsh maintains backward compatibility for history files.
  • No Extra Files: For the default setup, you only need the file pointed to by history file—there are no hidden auxiliary files required for basic history migration.

内容的提问来源于stack exchange,提问作者lincolnfrias

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 03:36:17