Metadata-Version: 2.4
Name: mergething
Version: 0.1.4
Summary: App over syncthing that takes care merging things
Project-URL: Homepage, https://github.com/drorspei/mergething
Project-URL: Repository, https://github.com/drorspei/mergething
Author-email: Dror Speiser <drorspei@gmail.com>
License: MIT
License-File: LICENSE.txt
Keywords: history,ipython,jupyter,merge,sync,syncthing
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Systems Administration
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# mergething

App over syncthing that takes care merging things

Install using `pip install mergething`

## ipython/jupyter

Currently supports merging ipython/jupyter history files.

mergething will give each ipython/jupyter session it's own history file, so in contrast to vanilla ipython, you can run multiple ipython sessions at the same time without worrying about corruption. You can even use mergething on a single machine in order to get this benefit.

When a session is closed, its history file is marked "completed", and once it is incorporated into a new session, it will be deleted (only ever by the same device).

# IPython/jupyter History Sync

## 1. Configure Syncthing

Set up Syncthing to sync a directory across your machines (e.g., `~/syncthing/ipython_history`).

## 2a. Configure IPython using CLI tool

The following line will copy your exisiting history file to the directory and add lines to you `ipython_config.py` file to use mergething:

`mergething init ~/syncthing/ipython_history`

## 2b. Configure IPython manually

Alternatively, you can add these lines to the end of your IPython configuration file manually (`~/.ipython/profile_default/ipython_config.py`):

```python
try:
    from mergething.ipython import sync_and_get_hist_file
    c.HistoryManager.hist_file = sync_and_get_hist_file("~/syncthing/ipython_history", verbose=False)
except Exception:
    print("mergething: Error syncing and getting history file, using default ipython behavior")
```

You can also pass the hostname you want files to use, this is useful when multiple devices have the same hostname:

```python
    c.HistoryManager.hist_file = sync_and_get_hist_file("~/syncthing/ipython_history", verbose=False, hostname="mydevice")
```

For Android/Termux users where the hostname is always "localhost", you can specify a custom hostname:

```python
try:
    from mergething.ipython import sync_and_get_hist_file
    c.HistoryManager.hist_file = sync_and_get_hist_file("~/syncthing/ipython_history", verbose=False, hostname="my_phone")
except Exception:
    print("mergething: Error syncing and getting history file, using default ipython behavior")
```

## Merging existing files

You can use the CLI tool to merge existing files:

`mergething merge history1.sqlite history2.sqlite ... historyn.sqlite merged_history.sqlite`
