1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-08 01:28:02 +00:00

Add Change The Current Directory For psql as a postgres til

This commit is contained in:
jbranchaud
2016-04-29 12:54:57 -05:00
parent f2d08564e5
commit a01d16f8e9
2 changed files with 27 additions and 1 deletions

View File

@@ -0,0 +1,25 @@
# Change The Current Directory For psql
When you start a `psql` session, your current directory is what `psql` will
use as its current directory. This is important for meta-commands that use
relative paths based on the current directory -- for instance, the `\i`
meta-command for importing files.
You can change the current directory within a `psql` session using the `\cd`
meta-command.
If my current directory is `home` and there is a `sql` directory in `home,
these commands will do the following:
```sql
\! pwd
/home
\cd sql
\! pwd
/home/sql
```
The `\cd` meta-command even supports tab completion relative to the current
directory.
You can also change to your home directory using just `\cd`.