Skip to content

Commit 5324a58

Browse files
authored
Update dev-tip-console-output-to-clipboard.md
1 parent 601d16b commit 5324a58

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

docs/linux/dev-tip-console-output-to-clipboard.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@ Add this to your `~/.zshrc`:
2828
# Toggle: set AUTO_CLIPBOARD=true/false
2929
AUTO_CLIPBOARD=true
3030

31+
# Redirect stdout+stderr to ~/t.txt before each command
3132
preexec() {
32-
# Redirect stdout+stderr to ~/t.txt before each command
33-
exec > >(tee ~/t.txt) 2>&1
33+
case "$1" in
34+
sudo*|su*) return ;;
35+
*) exec > >(tee ~/t.txt) 2>&1 ;;
36+
esac
3437
}
3538

3639
precmd() {

0 commit comments

Comments
 (0)