By default, if you press Page Up/Down, Home, or End in the Terminal, you will see less-than-helpful characters appear. Here’s how to fix it:
Step 1 (Configure Terminal):
Open Preferences (Command+,) and go to Settings, Keyboard
To change a key, find it in the list and hit “Edit” (or “+” if it’s not in the list). Change the action to “Send string to shell:” and use the following keycodes. IMPORTANT NOTE: Use the escape key (“esc”) for \033, do not enter it as text.
You may also want to set Shift Page Up/Down to “scroll to previous/next page in buffer”
Step 2 (Configure bash, optional):
You’ll need a correct /etc/inputrc (file may not already exist). Again, you may make this user-specific if you put it in ~/.inputrc instead.
"\e[1~": beginning-of-line "\e[4~": end-of-line "\e[5~": history-search-backward "\e[6~": history-search-forward "\e[3~": delete-char "\e[2~": quoted-insert "\e[5C": forward-word "\e[5D": backward-word "\e\e[C": forward-word "\e\e[D": backward-word set completion-ignore-case On
Step 3 (Set correct permissions):
You should set the correct permissions and ownership for security reasons:
For files in /etc
$ sudo chown root:staff /etc/bashrc /etc/inputrc
$ sudo chmod 644 /etc/bashrc /etc/inputrc
Or alternatively for files in ~
$ chmod 644 ~/.bashrc ~/.inputrc