HyperCwd 项目教程

HyperCwd 项目教程

hypercwd Opens new tabs with the same directory as the current tab in Hyper 项目地址: https://gitcode.com/gh_mirrors/hy/hypercwd

1. 项目的目录结构及介绍

HyperCwd 是一个用于在 Hyper 终端中打开新标签页时保持当前目录的项目。以下是项目的目录结构及其介绍:

hypercwd/
├── .npmignore
├── LICENSE
├── README.md
├── configParse.js
├── fixPath.js
├── index.js
├── linuxActionHandler.js
├── newTabs.gif
├── package.json
├── setCwd.js
└── windowsActionHandler.js
  • .npmignore: 用于指定在发布到 npm 时需要忽略的文件。
  • LICENSE: 项目的开源许可证文件,本项目使用 MIT 许可证。
  • README.md: 项目的说明文档,包含项目的简介、安装方法和配置说明。
  • configParse.js: 用于解析配置文件的脚本。
  • fixPath.js: 用于修复路径的脚本。
  • index.js: 项目的入口文件,负责初始化和启动项目。
  • linuxActionHandler.js: 用于处理 Linux 系统下的操作。
  • newTabs.gif: 展示新标签页功能的 GIF 动画。
  • package.json: 项目的配置文件,包含项目的依赖、脚本等信息。
  • setCwd.js: 用于设置当前工作目录的脚本。
  • windowsActionHandler.js: 用于处理 Windows 系统下的操作。

2. 项目的启动文件介绍

项目的启动文件是 index.js,它是整个项目的入口点。以下是 index.js 的主要功能介绍:

// index.js
const { setCwd } = require('./setCwd');
const { fixPath } = require('./fixPath');
const { configParse } = require('./configParse');
const { linuxActionHandler } = require('./linuxActionHandler');
const { windowsActionHandler } = require('./windowsActionHandler');

module.exports = (hyper) => {
  const { decorateConfig } = hyper;

  return {
    onApp: () => {
      setCwd();
    },
    onWindow: (window) => {
      fixPath(window);
    },
    decorateConfig: (config) => {
      return configParse(config);
    },
    onAction: (action, state) => {
      if (process.platform === 'linux') {
        linuxActionHandler(action, state);
      } else if (process.platform === 'win32') {
        windowsActionHandler(action, state);
      }
    }
  };
};
  • setCwd: 设置当前工作目录。
  • fixPath: 修复路径问题。
  • configParse: 解析配置文件。
  • linuxActionHandler: 处理 Linux 系统下的操作。
  • windowsActionHandler: 处理 Windows 系统下的操作。

3. 项目的配置文件介绍

项目的配置文件是 ~/.hyper.js,用户可以通过编辑该文件来配置 HyperCwd 插件。以下是一个示例配置:

module.exports = {
  config: {
    // 默认字体大小
    fontSize: 14,
    // 其他配置选项
    hypercwd: {
      initialWorkingDirectory: '~/Documents'
    }
  },
  plugins: [
    'hypercwd'
  ]
};
  • fontSize: 设置终端的字体大小。
  • hypercwd: HyperCwd 插件的配置对象。
    • initialWorkingDirectory: 设置初始工作目录的路径。

通过以上配置,用户可以自定义 HyperCwd 的行为,例如设置新标签页的初始工作目录。

hypercwd Opens new tabs with the same directory as the current tab in Hyper 项目地址: https://gitcode.com/gh_mirrors/hy/hypercwd

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

余靖年Veronica

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值