Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,30 @@ cdir helps you to switch quickly and easily between directories
Usage: cdir [OPTIONS] [COMMAND]

Commands:
gui Launch the GUI
config-file Print the path to the configuration file
add-path Add a directory path
import-paths Import a path file
add-shortcut Add a shortcut
delete-shortcut Delete a shortcut
print-shortcut Print a shortcut
import-shortcuts Import a shortcuts file
lasts Print last paths
pretty-print-path Pretty print a path using shortcuts
help Print this message or the help of the given subcommand(s)
gui Launch the GUI
config-file Print the path to the configuration file
add-path Add a directory path
add-shortcut Add a shortcut
delete-shortcut Delete a shortcut
print-shortcut Print a shortcut
lasts Print last paths
pretty-print-path Pretty print a path using shortcuts
import-paths Import a path file
export-paths Export paths to a YAML file
import-path-history Import path history file
export-path-history Export path history to a YAML file
import-shortcuts Import a shortcuts file
export-shortcuts Export shortcuts to a YAML file
help Print this message or the help of the given subcommand(s)

Options:
-c, --config-file <config_file> Path to the configuration file
-h, --help Print help
-V, --version Print version
```

You can report to the following sections of for more details:
You can refer to the following sections for more details:

* `import-paths` [Importing Shortcuts](importing_shortcuts.md)
* Import/Export commands: [Data Import & Export](importing_shortcuts.md)

* `pretty-print-path` [Shell promp](prompt.md)
* `pretty-print-path`: [Shell prompt](prompt.md)
11 changes: 9 additions & 2 deletions docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,16 @@ It is disabled by default but can be activated in the configuration file.

Works with both `zsh` and `bash`. More shells may be supported in the future.

## :material-check-bold: Import shortcuts
## :material-check-bold: Data import & export

Define your shortcuts in a YAML file and import them on any computer for easy setup.
Export and import your shortcuts, current paths, and complete directory history in YAML format.

Perfect for:

- **Backup**: Save your navigation data
- **Migration**: Move your setup to a new computer
- **Sharing**: Share shortcuts with your team
- **Version Control**: Keep your shortcuts in git with your dotfiles

## :material-check-bold: Color themes

Expand Down
153 changes: 153 additions & 0 deletions docs/import_export.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# Data Import & Export

`cdir` supports importing and exporting your data in YAML format, making it easy to:

- **Backup** your shortcuts and directory history
- **Share** shortcuts with teammates or across machines
- **Migrate** your data to a new computer

## Export Commands

### Export Shortcuts

Export all your shortcuts (bookmarks) to a YAML file:

```bash
$ cdir export-shortcuts ~/my-shortcuts.yaml
```

The exported file will contain:

```yaml
- name: projects
path: /home/user/projects
description: My projects folder
- name: docs
path: /home/user/Documents
description: null
```

### Export Paths

Export the current list of paths from your navigation history:

```bash
$ cdir export-current-paths ~/current-paths.yaml
```

This exports the most recent unique paths you've visited.

### Export Path History

Export the complete path history including multiple visits to the same directory:

```bash
$ cdir export-path-history ~/full-history.yaml
```

The exported file will contain:

```yaml
- date: '1740488400'
path: /home/user/projects
- date: '1740488350'
path: /home/user/Documents
- date: '1740488300'
path: /home/user/projects
```

Each entry includes a UNIX timestamp (seconds since epoch).

## Import Commands

### Import Shortcuts

Import shortcuts from a YAML file:

```bash
$ cdir import-shortcuts ~/my-shortcuts.yaml
```

The file should contain shortcuts with `name` and `path` fields:

```yaml
- name: proj
path: /home/user/projects
- name: tmp
path: /tmp
description: Temporary directory
```

### Import Paths

Import paths into both the current paths and history:

```bash
$ cdir import-paths ~/current-paths.yaml
```

This updates your current navigation state. The file format is:

```yaml
- date: '1740488400'
path: /home/user/projects
- date: '1740488350'
path: /home/user/Documents
```

### Import Path History

Import historical path data without affecting your current paths:

```bash
$ cdir import-path-history ~/full-history.yaml
```

**Important difference:** Unlike `import-paths`, this command only adds entries to the `paths_history` table and does NOT update your current paths. This is useful for:

- Merging historical data from multiple machines
- Restoring old navigation history
- Importing archived path data

## Common Use Cases

### Backup Everything

```bash
# Create a backup directory
mkdir ~/cdir-backup

# Export all your data
cdir export-shortcuts ~/cdir-backup/shortcuts.yaml
cdir export-current-paths ~/cdir-backup/current.yaml
cdir export-path-history ~/cdir-backup/history.yaml
```

### Setup a New Machine

```bash
# On the new machine, import your data
cdir import-shortcuts ~/cdir-backup/shortcuts.yaml
cdir import-path-history ~/cdir-backup/history.yaml
cdir import-paths ~/cdir-backup/current.yaml
```

### Share Shortcuts with Your Team

```bash
# Create a team shortcuts file
cat > team-shortcuts.yaml << EOF
- name: api
path: /company/projects/api
description: Main API service
- name: frontend
path: /company/projects/frontend
description: React frontend
- name: docs
path: /company/docs
description: Company documentation
EOF

# Everyone can import it
cdir import-shortcuts team-shortcuts.yaml
```
21 changes: 0 additions & 21 deletions docs/importing_shortcuts.md

This file was deleted.

2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ nav:
- GUI: gui.md
- Installation: installation.md
- Configuration: configuration.md
- Importing Shortcuts: importing_shortcuts.md
- Data Import & Export: import_export.md
- Shell promp: prompt.md
- License: license.md
theme:
Expand Down
Loading