# Cli Tools

## git

### 如何迁移当前更改到新的分支

Ref: [git 将当前分支上修改的东西转移到新建分支](https://blog.csdn.net/stan_pcf/article/details/51911101) 优雅的解决方案：压栈更改再弹出更改

1. 在修改的分支上 git stash 可以将当前更改的结果压栈到临时保存区内
2. 新建分支 git checkout -b new\_branch
3. 将当前的临时保存弹出 git stash pop

### git clone 慢

通过代理可以加快速度： 临时：

```bash
git clone -c http.proxy="http://127.0.0.1:1080" repourl
```

永久：

```bash
git config --global http.proxy "http://127.0.0.1:1080"
```

效果对比：

```bash
Before: 4.00 KiB/s
After:  1.82 MiB/s
```

## npm

### nrm

> Description: source controller for npm

**Install:**

> (sudo) npm install -g nrm\
> Admin rigths required.

**Usage:**

1. nrm ls : check all sources
2. nrm add \[name] `https://address` : add new source
3. nrm del \[name] : delete a source
4. nrm use \[name] : switch to a source
5. nrm test : test the speed of all sources

### vue

```bash
sudo npm install -g @vue/cli
```

## ag

### Ubuntu

保存并运行

```
set -x
TEMP_DIR=$(mktemp -d Leslie.Guan.XXXXXX)
cd ${TEMP_DIR}
wget https://github.com/ggreer/the_silver_searcher/archive/master.zip
TAR_DIR=$(unzip *.zip)
TAR_DIR=${TAR_DIR%%/*}
TAR_DIR=${TAR_DIR##*:}
cd ${TAR_DIR}
apt-get install -y automake pkg-config libpcre3-dev zlib1g-dev liblzma-dev --force-yes
./build.sh && make install
cd ../../
rm -rf ${TEMP_DIR}
ag -V
set +x
```

### yum

```bash
yum install the_silver_searcher
```

### macOs

```bash
brew install the_silver_searcher
```

## grep

[linux grep 查看指定内容上下几行](https://blog.csdn.net/huashao0602/article/details/78018743)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://legacy.cookielau.com/archives/4-linux/1-cli-tools.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
