How To Disable Bracketed Paste in BASH and ZSH

Bracketed paste is a feature in modern shells that helps prevent accidental execution of pasted commands by wrapping them in special escape sequences. However, some users find this behavior annoying, especially when pasting multi-line commands. Fortunately, it’s easy to disable bracketed paste in both BASH and ZSH.
Disabling Bracketed Paste in BASH
To turn off bracketed paste in BASH, modify your ~/.inputrc
file by adding the following line:
1 |
set enable-bracketed-paste off |
You can apply this change immediately by running:
1 |
bind -f ~/.inputrc |
Otherwise, restart your terminal or open a new session for the changes to take effect.
Disabling Bracketed Paste in ZSH
For ZSH users, disable bracketed paste by adding the following line to your ~/.zshrc
file:
1 |
unset zle_bracketed_paste |
After saving the file, reload your ZSH configuration with:
1 |
source ~/.zshrc |
Bonus: Enhancing TAB Completion
If you’re customizing your shell, consider tweaking TAB completion behavior to improve your experience. Add these lines to ~/.inputrc
for a more intuitive tab completion experience:
1 2 3 4 |
set bell-style none set completion-ignore-case on set show-all-if-ambiguous on TAB: menu-complete |
After modifying ~/.inputrc
, apply the changes with:
1 |
bind -f ~/.inputrc |
### Explanation of TAB Completion Tweaks:
set bell-style none
– Disables the terminal bell sound.set completion-ignore-case on
– Makes tab completion case-insensitive.set show-all-if-ambiguous on
– Displays all possible completions when multiple matches exist.TAB: menu-complete
– Enables menu-based tab completion.
With these tweaks, you can optimize your shell experience and eliminate unwanted behavior while improving command-line efficiency!
Extra Bonus: Dynamic Terminal Title
Sometimes my Terminal title gets stale, so I wanted a command to dynamically set it to the hostname and current working directory.
1 2 3 4 5 6 |
shell% vi setprompt #!/bin/bash export SHORTHOST=`hostname -s` printf "\033]0;${SHORTHOST}:${PWD}\007" shell% chmod 755 setprompt shell% ./setprompt |
This will set your terminal title to display the short hostname and current working directory, making navigation easier when working across multiple terminals.
Leave Your Comment
All fields marked with "*" are required.