diff --git a/README.md b/README.md index 5898d20..700c420 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really warrant a full blog post. These are mostly things I learn by pairing with smart people at [Hashrocket](http://hashrocket.com/). -_405 TILs and counting..._ +_406 TILs and counting..._ --- @@ -172,6 +172,7 @@ _405 TILs and counting..._ - [Adding Composite Uniqueness Constraints](postgres/adding-composite-uniqueness-constraints.md) - [Aggregate A Column Into An Array](postgres/aggregate-a-column-into-an-array.md) - [Auto Expanded Display](postgres/auto-expanded-display.md) +- [Change The Current Directory For psql](postgres/change-the-current-directory-for-psql.md) - [Checking The Type Of A Value](postgres/checking-the-type-of-a-value.md) - [Clear The Screen In psql](postgres/clear-the-screen-in-psql.md) - [Clear The Screen In psql (2)](postgres/clear-the-screen-in-psql-2.md) diff --git a/postgres/change-the-current-directory-for-psql.md b/postgres/change-the-current-directory-for-psql.md new file mode 100644 index 0000000..e5bb620 --- /dev/null +++ b/postgres/change-the-current-directory-for-psql.md @@ -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`.