diff --git a/README.md b/README.md index fbfd16d..7cf137d 100644 --- a/README.md +++ b/README.md @@ -19,32 +19,59 @@ JUMPING 是一个基于 Rust 开发的极轻量级 TUI 目录导航工具。它 ## 🚀 安装与配置 -### 下载预编译二进制文件 +### 使用脚本一键安装(推荐) -从 [GitHub Releases](https://github.com/harkerhand/jumping/releases) 下载对应平台的二进制文件: +我们提供了自动安装脚本,可以自动检测系统类型、下载对应二进制文件、安装到合适位置,并配置 Shell 环境: + +**方式一:下载脚本后运行** + +```bash +# 下载安装脚本 +wget https://raw.githubusercontent.com/harkerhand/jumping/main/install.sh +chmod +x install.sh +./install.sh +``` + +**方式二:直接运行(如果系统支持)** ```bash -# Linux -wget https://github.com/harkerhand/jumping/releases/latest/download/jumping-linux -chmod +x jumping-linux -sudo mv jumping-linux /usr/local/bin/jumping - -# macOS -wget https://github.com/harkerhand/jumping/releases/latest/download/jumping-macos -chmod +x jumping-macos -sudo mv jumping-macos /usr/local/bin/jumping +# 通过 curl 直接运行 +curl -sSL https://raw.githubusercontent.com/harkerhand/jumping/main/install.sh | bash ``` -### 从源码编译 +脚本功能: + +- ✅ 自动检测操作系统(Linux/macOS) +- ✅ 自动检测 Shell 类型(Bash/Zsh/Fish) +- ✅ 智能选择安装路径(系统目录或用户目录) +- ✅ 自动配置 Shell 环境 +- ✅ 交互式安装,可选择自动添加配置 + +### 手动安装 + +1. **下载二进制文件:** + 从 [GitHub Releases](https://github.com/harkerhand/jumping/releases) 下载对应平台的二进制文件: + + ```bash + # Linux + wget https://github.com/harkerhand/jumping/releases/latest/download/jumping-linux + chmod +x jumping-linux + sudo mv jumping-linux /usr/local/bin/jumping + + # macOS + wget https://github.com/harkerhand/jumping/releases/latest/download/jumping-macos + chmod +x jumping-macos + sudo mv jumping-macos /usr/local/bin/jumping + ``` -1. **编译源码:** +2. 如果你想从源代码编译安装,可以使用以下命令: ```bash cargo build --release cp target/release/jumping /usr/local/bin/ ``` -2. **配置 Shell:** +3. **配置 Shell:** 将以下内容添加到你的 Shell 配置文件中,以启用跳转功能(这会创建一个`jp`函数): 对于 Bash 或 Zsh 用户,请添加: @@ -81,4 +108,5 @@ sudo mv jumping-macos /usr/local/bin/jumping * `j` / `k` 或 `↑` / `↓`: 在同级目录间上下切换。 * `h` / `l` 或 `←` / `→`: 在父目录与子目录间层级穿梭。 * `Enter`: 确认选择并直接跳转。 +* `i`: 切换是否显示隐藏文件夹。 * `q` / `Esc`: 退出工具并保持原位。 diff --git a/README_EN.md b/README_EN.md index 14d8268..46a1155 100644 --- a/README_EN.md +++ b/README_EN.md @@ -1,85 +1,113 @@ -## [English](README_EN.md) | [中文](README.md) +## [English](https://www.google.com/search?q=README_EN.md) | [中文](README.md)
- JUMPING Logo +JUMPING Logo
# 🛰️ JUMPING > **J**umping **U**nlocks **M**ulti-path **P**recise **I**nstant **N**avigating **G**ear. -JUMPING is a blazingly fast, lightweight TUI directory navigator built in Rust. It solves -the "deep path fatigue" by providing a 3-column Miller column view to preview and teleport between directories -instantly. +JUMPING is an ultra-lightweight TUI directory navigation tool built with Rust. It eliminates the friction of navigating +deep terminal paths via a three-column layout, allowing you to "teleport" between folders instantly. -## ✨ Key Features +--- -* **💨 Lightning Fast**: Zero-dependency runtime, minimal resource footprint. -* **📂 Miller Columns**: 3-pane layout (Parent, Current, Preview) inspired by macOS Finder/Ranger. -* **⌨️ Vim-like Motion**: Navigate with `h/j/k/l` or arrow keys. -* **🎯 Instant Teleport**: Exit and `cd` to the selected directory automatically via shell wrapper. +## ✨ Features -## 🚀 Installation & Setup +* **💨 Blazing Fast**: Written in Rust with zero runtime dependencies—pure performance. +* **📂 Three-Column View**: A macOS Finder-style layout (Parent-Current-Preview) for clear structural context. +* **⌨️ Vim-like Motion**: Supports `h/j/k/l` and arrow keys for intuitive navigation. +* **🎯 Seamless Jump**: Integrated Shell wrapper enables automatic `cd` to the target location upon exit. -### Download Pre-built Binaries +--- -Download the pre-built binaries from [GitHub Releases](https://github.com/harkerhand/jumping/releases): +## 🚀 Installation & Configuration + +### One-Click Installation (Recommended) + +We provide an automated script that detects your system, downloads the correct binary, installs it, and configures your +Shell environment: + +**Option 1: Download and Run** ```bash -# Linux -wget https://github.com/harkerhand/jumping/releases/latest/download/jumping-linux -chmod +x jumping-linux -sudo mv jumping-linux /usr/local/bin/jumping - -# macOS -wget https://github.com/harkerhand/jumping/releases/latest/download/jumping-macos -chmod +x jumping-macos -sudo mv jumping-macos /usr/local/bin/jumping +# Download the installer +wget https://raw.githubusercontent.com/harkerhand/jumping/main/install.sh +chmod +x install.sh +./install.sh + ``` -### Build from Source +**Option 2: Direct Pipe (if supported)** + +```bash +# Run via curl +curl -sSL https://raw.githubusercontent.com/harkerhand/jumping/main/install.sh | bash + +``` -1. **Build from source:** +**Script Capabilities:** - ```bash - cargo build --release - cp target/release/jumping /usr/local/bin/ - ``` +* ✅ Auto-detects OS (Linux/macOS) +* ✅ Auto-detects Shell type (Bash/Zsh/Fish) +* ✅ Intelligent path selection (System or User bin) +* ✅ Automatic Shell environment configuration +* ✅ Interactive setup for profile updates + +--- + +### Manual Installation + +1. **Download Binary:** + Download the specific version for your platform + from [GitHub Releases](https://github.com/harkerhand/jumping/releases): + + ```bash + # Linux + wget https://github.com/harkerhand/jumping/releases/latest/download/jumping-linux + chmod +x jumping-linux + sudo mv jumping-linux /usr/local/bin/jumping + + # macOS + wget https://github.com/harkerhand/jumping/releases/latest/download/jumping-macos + chmod +x jumping-macos + sudo mv jumping-macos /usr/local/bin/jumping + + ``` + +2. **Build from Source (Optional):** + + ```bash + cargo build --release + cp target/release/jumping /usr/local/bin/ + + ``` + +3. **Configure Shell:** + Add the following to your Shell profile to enable the `jp` jump function: + **For Bash or Zsh:** -2. **Configure the shell:** - 将以下内容添加到你的 Shell 配置文件中,以启用跳转功能(这会创建一个`jp`函数): - For Bash or Zsh users, add: ```bash eval "$(jumping --init)" ``` - For Fish users, add: + + **For Fish:** + ```fish jumping --init fish | source ``` - You can also run `jumping --init` directly to see the corresponding shell configuration command. - For example, running in zsh will give you: - ```bash - jp() { - local TMP_FILE="/tmp/jumping-1000" - [ -f "$TMP_FILE" ] && rm "$TMP_FILE" - - jumping - - if [ -f "$TMP_FILE" ]; then - local DEST=$(cat "$TMP_FILE") - if [ -d "$DEST" ]; then - cd "$DEST" - pwd - fi - rm "$TMP_FILE" - fi - } - ``` - -## 🎮 Usage +> [!TIP] +> Run `jumping --init` manually to see the underlying script. For example, in Zsh, it creates a `jp()` function that +> handles the temporary file hand-off for the `cd` command. + +--- + +## 🎮 Controls -* `j` / `k` or `↑` / `↓`: Move up and down within the current directory. -* `h` / `l` or `←` / `→`: Traverse through directory hierarchy. -* `Enter`: Confirm selection and teleport. -* `q` / `Esc`: Quit without changing directory. +* **`j` / `k**` or **`↑` / `↓**`: Move up and down within the current directory. +* **`h` / `l**` or **`←` / `→**`: Traverse between parent and child directories. +* **`Enter`**: Confirm selection and jump to the directory. +* **`i`**: Toggle visibility of hidden files/folders. +* **`q` / `Esc**`: Quit the tool and stay in the current directory. diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..91e6795 --- /dev/null +++ b/install.sh @@ -0,0 +1,272 @@ +#!/bin/bash + +# JUMPING 安装脚本 +# 下载预编译二进制文件并配置 Shell 环境 + +set -e + +# 颜色定义 +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# 输出函数 +log_info() { + echo -e "${BLUE}[INFO]${NC} $1" +} + +log_success() { + echo -e "${GREEN}[SUCCESS]${NC} $1" +} + +log_warn() { + echo -e "${YELLOW}[WARNING]${NC} $1" +} + +log_error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +# 检测系统类型 +detect_system() { + case "$(uname -s)" in + Linux*) SYSTEM="linux";; + Darwin*) SYSTEM="macos";; + *) SYSTEM="unknown" + esac + + echo "$SYSTEM" +} + +# 检测系统架构(可选) +detect_arch() { + case "$(uname -m)" in + x86_64|amd64) ARCH="x86_64";; + arm64|aarch64) ARCH="aarch64";; + *) ARCH="unknown" + esac + + echo "$ARCH" +} + +# 检测下载工具 +detect_download_tool() { + if command -v curl &> /dev/null; then + echo "curl" + elif command -v wget &> /dev/null; then + echo "wget" + else + echo "none" + fi +} + +# 下载文件 +download_file() { + local url="$1" + local output="$2" + local tool="$3" + + log_info "下载: $url" + + if ! case "$tool" in + curl) + curl -L -o "$output" "$url" + ;; + wget) + wget -O "$output" "$url" + ;; + *) + log_error "未找到 curl 或 wget,请安装其中一个下载工具" + exit 1 + ;; + esac; then + log_error "下载失败: $url" + exit 1 + fi +} + +# 检测 Shell 类型 +detect_shell() { + local shell_name + shell_name="$(basename "$SHELL")" + + case "$shell_name" in + bash) echo "bash";; + zsh) echo "zsh";; + fish) echo "fish";; + *) echo "unknown";; + esac +} + +# 获取 Shell 配置文件路径 +get_shell_config() { + local shell_type="$1" + + case "$shell_type" in + bash) + if [ -f "$HOME/.bashrc" ]; then + echo "$HOME/.bashrc" + elif [ -f "$HOME/.bash_profile" ]; then + echo "$HOME/.bash_profile" + else + echo "$HOME/.bashrc" + fi + ;; + zsh) + if [ -f "$HOME/.zshrc" ]; then + echo "$HOME/.zshrc" + else + echo "$HOME/.zshrc" + fi + ;; + fish) + echo "$HOME/.config/fish/config.fish" + ;; + *) + echo "" + ;; + esac +} + +# 主安装函数 +main() { + log_info "开始安装 JUMPING..." + + # 检测系统 + SYSTEM=$(detect_system) + if [ "$SYSTEM" = "unknown" ]; then + log_error "不支持的操作系统: $(uname -s)" + exit 1 + fi + log_info "检测到系统: $SYSTEM" + + # 检测下载工具 + DOWNLOAD_TOOL=$(detect_download_tool) + log_info "使用下载工具: $DOWNLOAD_TOOL" + + # 定义下载链接 + BINARY_NAME="jumping-$SYSTEM" + DOWNLOAD_URL="https://github.com/harkerhand/jumping/releases/latest/download/$BINARY_NAME" + log_info "下载链接: $DOWNLOAD_URL" + + # 临时目录 + TEMP_DIR=$(mktemp -d) + DOWNLOAD_PATH="$TEMP_DIR/jumping" + + # 下载二进制文件 + log_info "下载预编译二进制文件..." + download_file "$DOWNLOAD_URL" "$DOWNLOAD_PATH" "$DOWNLOAD_TOOL" + + # 设置执行权限 + chmod +x "$DOWNLOAD_PATH" + log_success "二进制文件已下载并设置可执行权限" + + # 安装到系统路径 + INSTALL_DIR="/usr/local/bin" + INSTALL_PATH="$INSTALL_DIR/jumping" + + log_info "尝试安装到: $INSTALL_PATH" + + if [ ! -w "$INSTALL_DIR" ]; then + log_warn "需要 sudo 权限来安装到 $INSTALL_DIR" + if ! sudo -v; then + log_error "sudo 认证失败,尝试安装到用户目录" + USER_INSTALL_DIR="$HOME/.local/bin" + mkdir -p "$USER_INSTALL_DIR" + INSTALL_DIR="$USER_INSTALL_DIR" + INSTALL_PATH="$INSTALL_DIR/jumping" + log_info "将安装到: $INSTALL_PATH" + else + sudo cp "$DOWNLOAD_PATH" "$INSTALL_PATH" + sudo chmod +x "$INSTALL_PATH" + fi + else + cp "$DOWNLOAD_PATH" "$INSTALL_PATH" + chmod +x "$INSTALL_PATH" + fi + + if [ -f "$INSTALL_PATH" ]; then + log_success "JUMPING 已安装到: $INSTALL_PATH" + else + cp "$DOWNLOAD_PATH" "$INSTALL_PATH" + chmod +x "$INSTALL_PATH" + log_success "JUMPING 已安装到: $INSTALL_PATH" + fi + + # 清理临时文件 + rm -rf "$TEMP_DIR" + + # 检测 Shell 类型 + SHELL_TYPE=$(detect_shell) + log_info "检测到 Shell: $SHELL_TYPE" + + # 配置 Shell + log_info "配置 Shell 环境..." + + if [ "$SHELL_TYPE" = "unknown" ]; then + log_warn "未知 Shell 类型,请手动配置" + echo "" + echo "请手动运行以下命令来配置 Shell:" + echo " jumping --init" + echo "" + echo "然后将输出内容添加到您的 Shell 配置文件中。" + else + CONFIG_FILE=$(get_shell_config "$SHELL_TYPE") + + echo "" + echo "================================================" + log_success "JUMPING 安装完成!" + echo "" + echo "接下来请将以下配置添加到您的 Shell 配置文件中:" + echo "配置文件: $CONFIG_FILE" + echo "" + + # 运行 jumping --init 获取配置 + if command -v jumping &> /dev/null; then + echo "运行以下命令获取配置:" + echo " jumping --init" + echo "" + echo "或者直接运行以下命令自动添加配置:" + echo " echo 'eval \"\$(jumping --init)\"' >> $CONFIG_FILE" + + # 询问是否自动添加配置 + echo "" + read -p "是否自动添加配置到 $CONFIG_FILE? [y/N]: " -n 1 -r + echo "" + if [[ $REPLY =~ ^[Yy]$ ]]; then + if [ -f "$CONFIG_FILE" ]; then + { + echo "" >> "$CONFIG_FILE" + } + echo "# JUMPING configuration" >> "$CONFIG_FILE" + jumping --init >> "$CONFIG_FILE" + log_success "配置已添加到 $CONFIG_FILE" + echo "" + echo "请重新启动终端或运行: source $CONFIG_FILE" + else + log_warn "配置文件 $CONFIG_FILE 不存在,创建新文件" + jumping --init > "$CONFIG_FILE" + log_success "配置文件已创建: $CONFIG_FILE" + fi + fi + else + log_error "jumping 命令未找到,请检查安装路径是否在 PATH 中" + echo "请手动将 $INSTALL_DIR 添加到 PATH 环境变量" + fi + fi + + echo "" + echo "使用说明:" + echo " 1. 在终端中输入 'jp' 启动 JUMPING" + echo " 2. 使用方向键或 h/j/k/l 导航" + echo " 3. 按 Enter 选择目录并跳转" + echo " 4. 按 q 或 Esc 退出" + echo " 5. 按 I/i 切换隐藏文件夹显示" + echo "" + log_success "安装完成!" +} + +# 运行主函数 +main "$@" \ No newline at end of file