---
title: "BashとZshでシークレット（プライベート）なコマンドを実行する"
description: "コマンドの前にスペースを1つ入れるだけで、~/.bash\\_history に保存されなくなります。例： qrencode -o out.png \"Some secret text\""
canonical: https://oozou.com/til/run-incognito-private-commands-for-bash-and-zsh-112
locale: ja
date: 2020-12-08
topic: shell
---

# BashとZshでシークレット（プライベート）なコマンドを実行する

> コマンドの前にスペースを1つ入れるだけで、~/.bash\_history に保存されなくなります。例： qrencode -o out.png "Some secret text"

Published: 2020-12-08 · Topic: [shell](https://oozou.com/ja/til-topics/shell) ([markdown](https://oozou.com/ja/til-topics/shell.md))

# Bash

コマンドの前にスペースを1つ入れるだけで、`~/.bash\_history` に保存されなくなります。例：` qrencode -o out.png "Some secret text"`

# Zsh

以下のオプションを有効にすると、コマンドの前にスペースを付けてプライベートなコマンドを実行でき、`~/.zsh\_history` に保存されないようにできます。

```
setopt HIST_IGNORE_SPACE
```

---

Contact OOZOU: hello@oozou.com · +66 2544 0000 · https://oozou.com/ja/contact

More for AI agents: https://oozou.com/llms.txt · every page has a markdown twin at its URL plus ".md"
