<p>In this case I would create an alias?</p>
<pre><code>$ alias BCLI=&quot;bitcoin-cli -conf=/media/btc/bitcoin/bitcoin.conf&quot;
$ BCLI getblockcount
</code></pre>
<p>On Windows you may use <a href="https://superuser.com/a/560558">doskey</a>.</p>

CC BY-SA 4.0
2021-01-04T18:02:05.953Z
It's also common practice to use the same name when using `alias` for setting default options: `alias bitcoin-cli="bitcoin-cli -conf...`. If one ever wants to call the non-alias command, it's just a matter of prefixing the command name with a backslash to prevent alias expansion: `$ \bitcoin-cli ...`
JoL
CC BY-SA 4.0
2021-01-04T09:07:04.813Z
2021-01-04T10:42:24.830Z
2021-01-04T10:42:24.830Z
MCCCS
<p>I have changed the configuration directory for <code>bitcoind</code>.</p>
<p>However when I make a <code>bitcion-cli</code> request:</p>
<pre><code>bitcoin-cli getblockcount
</code></pre>
<p>I get an error about RPC credentials using <code>~/.bitcoin/bitcoin/conf</code></p>
<p>So for me to actually run the command with the correct config and authnetication cookie I have to specify the configuration directory explicitly <strong>every time</strong>. Is there a way to make it implicit?</p>
<pre><code>bitcoin-cli -conf=/media/btc/bitcoin/bitcoin.conf getblockcount
581510
</code></pre>

<bitcoin-cli>
Is there a way to give `bitcoin-cli` a different default conf directory instead of specifying it each time?
tread
# Is there a way to give `bitcoin-cli` a different default conf directory instead of specifying it each time?

(Asked by: username_0 on 2021-01-04)

I have changed the configuration directory for `bitcoind`.

However when I make a `bitcion-cli` request:

```
bitcoin-cli getblockcount

```

I get an error about RPC credentials using `~/.bitcoin/bitcoin/conf`

So for me to actually run the command with the correct config and authnetication cookie I have to specify the configuration directory explicitly **every time**. Is there a way to make it implicit?

```
bitcoin-cli -conf=/media/btc/bitcoin/bitcoin.conf getblockcount
581510

```

**Tags:** bitcoin-cli


---

## 1 answers

### Answer by username_1 on 2021-01-04. Score: 4

In this case I would create an alias?

```
$ alias BCLI="bitcoin-cli -conf=/media/btc/bitcoin/bitcoin.conf"
$ BCLI getblockcount

```

On Windows you may use [doskey](https://superuser.com/a/560558).

> **Comments:**
> **username_2**: It's also common practice to use the same name when using `alias` for setting default options: `alias bitcoin-cli="bitcoin-cli -conf...`. If one ever wants to call the non-alias command, it's just a matter of prefixing the command name with a backslash to prevent alias expansion: `$ \bitcoin-cli ...`  

---

