1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-10 10:38:01 +00:00

Compare commits

...

2 Commits

Author SHA1 Message Date
jbranchaud
d1bbbb8843 Add Include Multiple Tables In A pg_dump as a Postgres TIL 2022-06-04 19:58:19 -05:00
jbranchaud
84f4aa2edb Add Exclude A Command From The ZSH History File as a Unix TIL 2022-06-04 16:50:27 -05:00
3 changed files with 66 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
_1216 TILs and counting..._
_1218 TILs and counting..._
---
@@ -612,6 +612,7 @@ _1216 TILs and counting..._
- [Group By The Result Of A Function Call](postgres/group-by-the-result-of-a-function-call.md)
- [Idempotent Inserts](postgres/idempotent-inserts.md)
- [Include All Queries In The Log File](postgres/include-all-queries-in-the-log-file.md)
- [Include Multiple Tables In A pg_dump](postgres/include-multiple-tables-in-a-pg-dump.md)
- [Insert A Bunch Of Records With Generate Series](postgres/insert-a-bunch-of-records-with-generate-series.md)
- [Insert Just The Defaults](postgres/insert-just-the-defaults.md)
- [Inspect Progress Of Long-Running Create Index](postgres/inspect-progress-of-long-running-create-index.md)
@@ -1157,6 +1158,7 @@ _1216 TILs and counting..._
- [Do A Dry Run Of An rsync](unix/do-a-dry-run-of-an-rsync.md)
- [Do Not Overwrite Existing Files](unix/do-not-overwrite-existing-files.md)
- [Enable Multi-Select Of Results With fzf](unix/enable-multi-select-of-results-with-fzf.md)
- [Exclude A Command From The ZSH History File](unix/exclude-a-command-from-the-zsh-history-file.md)
- [Exclude A Directory With Find](unix/exclude-a-directory-with-find.md)
- [Exclude Certain Files From An rsync Run](unix/exclude-certain-files-from-an-rsync-run.md)
- [Figure Out The Week Of The Year From The Terminal](unix/figure-out-the-week-of-the-year-from-the-terminal.md)

View File

@@ -0,0 +1,26 @@
# Include Multiple Tables In A pg_dump
When the `pg_dump` command is given the `-t` flag, it will dump just the table
named with that flag. If you want to include multiple tables in the dump, you
just need to use the flag multiple times.
```bash
$ pg_dump -t users -t users_roles -t roles my_database > roles.dump.sql
```
Alternatively, you can specify a
[pattern](https://www.postgresql.org/docs/current/app-psql.html#APP-PSQL-PATTERNS)
when using the `-t` flag.
```bash
$ pg_dump -t 'users*|roles' my_database > roles.dump.sql
```
You have to be a little more mindful of what will and won't be included when
crafting a pattern. It is a nice shortcut for a well-known or well-constrained
data model.
See the [`pg_dump`
docs](https://www.postgresql.org/docs/current/app-pgdump.html) for more
details, as well as [some
examples](https://www.postgresql.org/docs/current/app-pgdump.html#PG-DUMP-EXAMPLES).

View File

@@ -0,0 +1,37 @@
# Exclude A Command From The ZSH History File
The `zsh` shell can be configured to record the commands you run from the
terminal in a history file. This is great for recalling and retrieving past
commands that you want to run again.
What about commands that I don't want written to a file on my machine? For
instance, if I'm running a command that includes a password, secret key, or
some other sensitive value, I don't want that saved in plaintext on my machine.
`zsh` has an affordance for this with the `hist_ignore_space` option. With that
option enabled, any command preceded by a space (`' '`) will be excluded from
the history file.
First, turn it on.
```zsh
$ setopt hist_ignore_space
```
Now, try a couple commands and see what shows up in the file.
```zsh
$ echo 'this command will be saved in history'
this command will be saved in history
$ echo 'this will be kept secret'
this will be kept secret
$ tail ~/.zsh_history
: 1654378676:0;echo 'this command will be saved in history'
: 1654378690:0;tail ~/.zsh_history
```
Notice how the second command with the prefixed space is excluded.
[source](https://unix.stackexchange.com/a/6104/5916)