Skip to content

XingZhe-Li/Tp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tp - Directory Quick Jump CLI Tool

A lightweight Rust CLI tool for managing directory bookmarks and jumping between them quickly.


目录 | Contents


Features

  • Directory Bookmarks: Set short names for frequently used directories
  • Quick Jump: One-command jump to bookmarked directories
  • File Manager: Open bookmarked directories in system file manager
  • Back: Return to previous location after a jump
  • Interactive Selection: Fuzzy search with keyboard navigation
  • Shell Integration: Bash/Zsh/Fish/CMD support
  • Persistent Storage: Marks saved in config file
  • Import/Export: Easy migration and backup

Installation

# Build from source
cargo build --release
# Add target/release/tp (or tp.exe) to PATH

# Or use cargo install
cargo install --path .

Quick Start

# Add bookmark for current directory
tp add home

# Add bookmark for specific directory
tp add work ~/projects

# Jump to bookmarked directory (requires shell integration)
tp go work

# Open in file manager
tp open work

# Jump back to previous location
tp back

# List all bookmarks
tp list

# Remove a bookmark
tp remove home

Command Reference

Command Alias Description
tp add <name> [path] a Add bookmark (default: current dir)
tp go <name> g Output path (for shell integration)
tp open <name> o Open in file manager
tp back b Return to previous location
tp list ls List all bookmarks
tp remove <name> rm Remove bookmark
tp edit e Edit marks file
tp import <file> Import marks from file
tp export [file] Export marks to file
tp clean Remove invalid marks
tp shell-integration Output shell integration code
tp --version -V Show version

Shell Integration

Bash / Zsh

Add to ~/.bashrc or ~/.zshrc:

# tp jump function
function tp() {
    if [ -z "$1" ]; then
        local target
        target=$(tp go)
        if [ -n "$target" ]; then
            cd "$target"
        fi
    elif [ "$1" = "back" ] || [ "$1" = "b" ]; then
        cd "$(tp back)"
    else
        cd "$(tp go "$1")"
    fi
}

Or auto-add with:

# Bash
tp shell-integration bash >> ~/.bashrc

# Zsh
tp shell-integration zsh >> ~/.zshrc

Fish

Add to ~/.config/fish/config.fish:

function tp
    if test (count $argv) -eq 0
        cd (tp go)
    else if test "$argv[1]" = "back" -o "$argv[1]" = "b"
        cd (tp back)
    else
        cd (tp go $argv[1])
    end
end

CMD / Windows Batch

Save tp.bat to C:\Windows\System32 or any PATH location:

REM Generate tp.bat
tp shell-integration cmd > C:\Windows\System32\tp.bat

Usage:

C:\> tp work          :: Jump to work bookmark
C:\> tp               :: Interactive select
C:\> tp back          :: Return to previous
C:\> tp list          :: List bookmarks
C:\> tp add project   :: Add bookmark
C:\> tp open work     :: Open in file manager

Interactive Mode

Running tp go without arguments enters interactive selection:

> tp go
? Search:
> pro
  1. work     ~/projects/work
  2. project  ~/documents/project
  3. program  ~/downloads/program

 [↑/↓] Select  [Enter] Confirm  [Esc] Exit

Configuration

Marks are stored at ~/.tp/marks.toml (cross-platform):

[marks]
work = { path = "~/projects/work", created_at = "2026-01-01T00:00:00Z", use_count = 42 }
home = { path = "~/", created_at = "2026-01-01T00:00:00Z", use_count = 10 }

Similar Tools

  • zoxide - Smarter jump with ranking
  • autojump - Jump by frequency
  • z - Lightweight Bash jumper

License

MIT


tp - 路径快速跳转 CLI 工具

一个用 Rust 编写的轻量级目录书签管理工具,让你快速在常用目录间跳转。

功能特性

  • 目录书签: 为常用目录设置简短的名称标记
  • 快速跳转: 一键跳转到已标记的目录
  • 文件管理器打开: 在系统文件管理器中打开书签目录
  • 返回之前位置: 跳回 tp 之前所在的位置
  • 交互式选择: 模糊搜索 + 键盘导航选择
  • Shell 集成: 支持 Bash/Zsh/Fish/CMD 一键跳转
  • 持久化存储: 标记数据安全存储在配置文件中
  • 导入/导出: 方便迁移和备份

安装

# 从源码编译
cargo build --release
# 将 target/release/tp (或 tp.exe) 添加到 PATH

# 或使用 cargo install
cargo install --path .

快速开始

# 添加当前目录的书签
tp add home

# 添加指定目录的书签
tp add work ~/projects

# 跳转到书签目录 (需要配合 shell 函数使用)
tp go work

# 在文件管理器中打开书签目录
tp open work

# 跳回 tp 之前的位置
tp back

# 列出所有书签
tp list

# 删除书签
tp remove home

命令参考

命令 别名 说明
tp add <name> [path] a 添加书签,默认当前目录
tp go <name> g 输出目标路径 (用于 shell 集成)
tp open <name> o 在文件管理器中打开书签目录
tp back b 跳回 tp 之前的位置
tp list ls 列出所有书签
tp remove <name> rm 删除书签
tp edit e 编辑书签文件
tp import <file> 从文件导入书签
tp export [file] 导出书签到文件
tp clean 清理无效路径的书签
tp shell-integration 输出 shell 集成代码
tp --version -V 显示版本

Shell 集成

Bash / Zsh

将以下代码添加到 ~/.bashrc~/.zshrc:

# tp 跳转函数
function tp() {
    if [ -z "$1" ]; then
        # 无参数时,交互式选择
        local target
        target=$(tp go)
        if [ -n "$target" ]; then
            cd "$target"
        fi
    elif [ "$1" = "back" ] || [ "$1" = "b" ]; then
        # 跳回之前的位置
        cd "$(tp back)"
    else
        # 带参数时,直接跳转
        cd "$(tp go "$1")"
    fi
}

或直接运行以下命令自动添加:

# Bash
tp shell-integration bash >> ~/.bashrc

# Zsh
tp shell-integration zsh >> ~/.zshrc

Fish

添加到 ~/.config/fish/config.fish:

function tp
    if test (count $argv) -eq 0
        cd (tp go)
    else if test "$argv[1]" = "back" -o "$argv[1]" = "b"
        cd (tp back)
    else
        cd (tp go $argv[1])
    end
end

CMD / Windows 批处理

tp.bat 保存到 C:\Windows\System32 或其他 PATH 中的位置:

REM 运行以下命令生成 tp.bat 并保存
tp shell-integration cmd > C:\Windows\System32\tp.bat

使用方式:

C:\> tp work          :: 跳转到 work 书签
C:\> tp               :: 交互式选择
C:\> tp back          :: 返回之前位置
C:\> tp list          :: 列出所有书签
C:\> tp add project   :: 添加书签
C:\> tp open work     :: 在文件管理器中打开

交互式模式

不带参数运行 tp go 将进入交互式选择模式:

> tp go
? 输入搜索关键词:
> pro
  1. work     ~/projects/work
  2. project  ~/documents/project
  3. program  ~/downloads/program

 [↑/↓] 选择  [Enter] 确认  [Esc] 退出

配置文件

书签数据存储在统一路径 ~/.tp/marks.toml (Linux/Mac/Windows 通用):

[marks]
work = { path = "~/projects/work", created_at = "2026-01-01T00:00:00Z", use_count = 42 }
home = { path = "~/", created_at = "2026-01-01T00:00:00Z", use_count = 10 }

类似工具

  • zoxide - 更高级的智能跳转
  • autojump - 基于访问频率的跳转
  • z - 轻量级 Bash 跳转工具

License

MIT

About

A Simple CLI Tool That Serves As Bookmarks in Terminal

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages