---
title: "ターミナルがダサいとモテない。pierでTerminal Taskをひとまとめ | grasys blog"
url: "https://blog.grasys.io/post/yusukeh/terminal-pier"
description: "Command Line Frameworkが好き Photo by Sigmund on Unsplash 自分はCommand Line Frameworkが大好きなんですが・・・ またまた見つけてしまいました。 pierです。Rustで実装されてます。 GitHub pier cli/pier: A Linux script management CLI written in Rust A Linux script managem…"
---

# ターミナルがダサいとモテない。pierでTerminal Taskをひとまとめ

-   ![](/_astro/noicon.CTHOhNiB_1HMs6A.webp)[yusukeh](/authors/yusukeh/)
-   公開日：2025年5月22日
-   カテゴリー：[Tech](/categories/tech/)
-   タグ：[#シリーズ: ターミナル環境](/tags/シリーズ-ターミナル環境/)[#pier](/tags/pier/)[#CLI](/tags/cli/)

![ターミナルがダサいとモテない。pierでTerminal Taskをひとまとめ](/_astro/ogp.DWYwnOjv_mYJPr.webp)

Photo by [Sigmund](https://unsplash.com/@sigmund?utm_source=medium&utm_medium=referral) on [Unsplash](https://unsplash.com/?utm_source=medium&utm_medium=referral)

Command-Line Frameworkが好き

自分はCommand-Line Frameworkが大好きなんですが・・・  
またまた見つけてしまいました。

[pier](https://github.com/pier-cli/pier)です。Rustで実装されてます。

## GitHub - pier-cli/pier: A Linux script management CLI written in Rust

### A Linux script management CLI written in Rust. Contribute to pier-cli/pier development by creating an account on…

github.com

Command-Line Frameworkというと、自分はいろいろ活用してきました。

古くはPerlの[App::Cmd](https://metacpan.org/pod/App::Cmd)や[App::Rad](https://metacpan.org/pod/App::Rad)

bashの[rerun](https://rerun.github.io/rerun/)

こちらは自分でmedium書いてますね

## ターミナルがダサいとモテない。bash command-line framework rerun編

### bashのmodule型command-line framework rerun

medium.com

あとはRustで作られてる[argc](https://github.com/sigoden/argc)  
これも自分でmedium書いてますね。

## ターミナルがダサいとモテない。bash command-line framework argc編

### command-line frameworkは何を使っていますか？

medium.com

bashだと処理内容的に辛いな・・・ってときに、Pythonで書ける[Typer](https://typer.tiangolo.com/)

## Typer

### Typer, build great CLIs. Easy to code. Based on Python type hints.

typer.tiangolo.com

この通りCommand-Line Frameworkが大好きです。

今日は[pier](https://github.com/pier-cli/pier)を紹介しようと思います。

## pierの簡単な説明

githubのDescriptionに書いてありますね

## GitHub - pier-cli/pier: A Linux script management CLI written in Rust

### A Linux script management CLI written in Rust. Contribute to pier-cli/pier development by creating an account on…

github.com

scriptを書いて便利になったけど、いろんなサーバがあって  
PATHの設定が・・・  
script名の命名が・・・

作者の苛立ちが感じられます😅  
気持ちわかります👍

ざっくり自分の斜め読み理解で説明すると

-   Installはcargo install
-   tomlファイルでScript本体とそのメタデータを一元管理
-   pier本体とtomlだけで複数のscriptを持ち回れる

素敵じゃん🤣

んじゃさっそく始めてみます。

## pierのInstall

githubに見逃すレベルでさらっと書かれています。

## GitHub - pier-cli/pier: A Linux script management CLI written in Rust

### A Linux script management CLI written in Rust. Contribute to pier-cli/pier development by creating an account on…

github.com

Plain textcontent\_copy

```
cargo install pier
```

これで入ります。

## pierのpre-init

macOSだと${HOME}/Library/Preferences/pier/config.tomlがdefaultのconfig pathになっていて気持ち悪いのとdotfilesを[yadm](https://medium.com/@yusuke_h/%E3%82%BF%E3%83%BC%E3%83%9F%E3%83%8A%E3%83%AB%E3%81%8C%E3%83%80%E3%82%B5%E3%81%84%E3%81%A8%E3%83%A2%E3%83%86%E3%81%AA%E3%81%84-macos%E3%81%A8linux%E3%81%AExdg-config-home%E3%82%92%E5%85%B1%E6%9C%89%E3%81%99%E3%82%8B%E3%81%9E-yadm%E7%B7%A8-e4ce0effb03e)で管理できないので変更します。

helpを見ると・・・

Plain textcontent\_copy

```
pier --help
pier 0.1.6
Benjamin Scholtz, Isak Johansson
A simple script management CLI

USAGE:
    pier [FLAGS] [OPTIONS] <alias> [args]...
    pier [FLAGS] [OPTIONS] <SUBCOMMAND>

FLAGS:
    -h, --help
            Prints help information

    -V, --version
            Prints version information

    -v, --verbose
            The level of verbosity


OPTIONS:
    -c, --config-file <path>
            Sets a custom config file.

            DEFAULT PATH is otherwise determined in this order:

            - $PIER_CONFIG_PATH (environment variable if set)

            - pier.toml (in the current directory)

            - $XDG_CONFIG_HOME/pier/config.toml

            - $XDG_CONFIG_HOME/pier/config

            - $XDG_CONFIG_HOME/pier.toml

            - $HOME/.pier.toml

            - $HOME/.pier [env: PIER_CONFIG_PATH=]

ARGS:
    <alias>
            The alias or name for the script

    <args>...
            The positional arguments to send to script


SUBCOMMANDS:
    add            Add a new script to config
    config-init    alias: init - Add a config file
    copy           alias: cp - Copy existing alias to the new one
    edit           Edit a script matching alias
    help           Prints this message or the help of the given subcommand(s)
    list           alias: ls - List scripts
    move           alias: mv, rename - Move/rename existing alias to the new one
    remove         alias: rm - Remove a script matching alias
    run            Run a script matching alias
    show           Show a script matching alias
```

いくつかのパターンでconfig pathを設定できるみたいですね

Plain textcontent\_copy

```
DEFAULT PATH is otherwise determined in this order:

            - $PIER_CONFIG_PATH (environment variable if set)

            - pier.toml (in the current directory)

            - $XDG_CONFIG_HOME/pier/config.toml

            - $XDG_CONFIG_HOME/pier/config

            - $XDG_CONFIG_HOME/pier.toml

            - $HOME/.pier.toml

            - $HOME/.pier [env: PIER_CONFIG_PATH=]
```

ちょっと自分の場合は確実に設定したいのでbashrcに以下のように設定しました。

Plain textcontent\_copy

```
# pier
if command -v pier &> /dev/null; then
  declare -x PIER_CONFIG_PATH=${XDG_CONFIG_HOME}/pier/config.toml
fi
```

まあこれは自分の癖や気持ちの問題なので気にしないでください。

Plain textcontent\_copy

```
pier --help
```

環境変数を読み込ませるとHelpの出力のOptions -cの最後あたりに  
env: でPIER\_CONFIG\_PATHが出力されるので確認できます。

Plain textcontent\_copy

```
- $HOME/.pier [env: PIER_CONFIG_PATH=/Users/xxxxxx/.config/pier/config.toml]
```

## pier config-init

PIER\_CONFIG\_PATHを設定できたら環境変数が読み込まれてることを確認して以下を実行してみましょう。

Plain textcontent\_copy

```
pier config-init
```

## pier config.toml

config-initしたらこんな感じのtomlができます。

ひとつscriptもsampleの登録されます。

Plain textcontent\_copy

```
cat ${PIER_CONFIG_PATH}

[scripts.hello-pier]
command = 'echo Hello, Pier!'
description = 'This is an example command.'

[default]
```

## pier list

listで登録されてる一覧が確認できます。

Plain textcontent\_copy

```
pier list
≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖
⋮ Alias             ⋮ Tags ⋮ Command                                ⋮ Description                 ⋮
≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖
⋮ hello-pier        ⋮      ⋮ echo Hello, Pier!                      ⋮ This is an example command. ⋮
≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖≖
```

hello-pierは最初から登録されてます。

## pier run

実際にhello-pierを実行してみます。

Plain textcontent\_copy

```
pier run hello-pier
Hello, Pier!
```

実際にconfig.tomlを見ると

Plain textcontent\_copy

```
[scripts.hello-pier]
command = 'echo Hello, Pier!'
description = 'This is an example command.'
```

commandのパラメータを実行してます。

これでだいたいわかってきてると思うので次は実際に追加してみましょう。

## pier add

pier addでscriptsを追加できます。

ここではあくまでもサンプルとして[bat](https://github.com/sharkdp/bat)の[cacheを作り直し](https://github.com/sharkdp/bat?tab=readme-ov-file#adding-new-syntaxes--language-definitions)てます。

Plain textcontent\_copy

```
pier add \
  --alias rebuild-cache-bat \
  --description "Rebuilding the bat cache" \
  --tag bat \
  -- "bat cache --clear & bat cache --build"
Added rebuild-cache-bat
```

実際に登録したものを走らせてみます。

Plain textcontent\_copy

```
pier run rebuild-cache-bat
Clearing theme set cache ... okay
Clearing syntax set cache ... okay
Clearing metadata file ... okay
Writing theme set to /Users/xxxxxxxx/.cache/bat/themes.bin ... okay
Writing syntax set to /Users/xxxxxxxx/.cache/bat/syntaxes.bin ... okay
Writing metadata to folder /Users/xxxxxxxx/.cache/bat ... okay
```

## 感想

githubの[README](https://github.com/pier-cli)にも書いてある通りで、cargo installしてtomlをdotfilesで持っていくだけで一通りのscriptを持ち回れるのはとてもいい感じ

[README](https://github.com/pier-cli)を読むと

defaultのinterpriterを設定できるみたいでnodeなどの例もあるんで、全部nodeで書くとかなら設定するといいかも

## GitHub - pier-cli/pier: A Linux script management CLI written in Rust

### A Linux script management CLI written in Rust. Contribute to pier-cli/pier development by creating an account on…

github.com

shebangもtomlのヒアドキュメント形式で書けるみたいなので、自分はこっちの方が好みかな

## GitHub - pier-cli/pier: A Linux script management CLI written in Rust

### A Linux script management CLI written in Rust. Contribute to pier-cli/pier development by creating an account on…

github.com

あとは実際に登録するとき、ちょっと複雑なscriptであれば  
pier addのhelpに記載してある通りにやらないで

Plain textcontent\_copy

```
pier add --help
pier-add 0.1.6
Add a new script to config

USAGE:
    pier add [FLAGS] [OPTIONS] --alias <alias> [--] [command]

FLAGS:
    -f, --force      Allows to overwrite the existing script
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -a, --alias <alias>                The alias or name for the script
    -d, --description <description>    The description for the script
    -t, --tag <tags>...                Set which tags the script belongs to

ARGS:
    <command>    The command/script content to be executed. If this argument is not found it will open your $EDITOR
                 for you to enter the script into
```

commandの入力に適当に入れてtomlを編集した方がやりやすいかもしれないですね。

Plain textcontent\_copy

```
pier add [FLAGS] [OPTIONS] --alias <alias> [--] [ここに適当にいれて]

vi ${PIER_CONFIG_PATH}
```

ちょっと個人的に使ってみようかな

ターミナル環境について他の記事も書いているので、よろしければこちらもご覧ください！  
[『ターミナルがダサいとモテない』シリーズ一覧](https://blog.grasys.io/tags/series-terminal-update)

転載：[ターミナルがダサいとモテない。pierでTerminal Taskをひとまとめ](https://medium.com/@yusuke_h/%E3%82%BF%E3%83%BC%E3%83%9F%E3%83%8A%E3%83%AB%E3%81%8C%E3%83%80%E3%82%B5%E3%81%84%E3%81%A8%E3%83%A2%E3%83%86%E3%81%AA%E3%81%84-pier%E3%81%A7terminal-task%E3%82%92%E3%81%B2%E3%81%A8%E3%81%BE%E3%81%A8%E3%82%81-04a01f4de599)

この記事は [Medium（@yusuke\_h）](https://medium.com/@yusuke_h) からの転載です。

## この記事を書いた人

[![](/_astro/yusukeh.BvUd2yKE_1mQ6Fp.webp)](/authors/yusukeh/)

### [yusukeh](/authors/yusukeh/)

Fly high. Think deep. Move fast. Go far.🦅

-   [X](https://x.com/yusukeh "X")
-   [GitHub](https://github.com/yusukeh "GitHub")
-   [Medium](https://medium.com/@yusukeh "Medium")
-   [Facebook](https://www.facebook.com/yusuke.exzm "Facebook")
-   [Instagram](https://www.instagram.com/yusukehasegawa/ "Instagram")
-   [LinkedIn](https://www.linkedin.com/in/hasegawa-yusuke-091b4164/ "LinkedIn")

[プロフィールと記事一覧](/authors/yusukeh/)