in Terminal > File > Preferences
change the following keyboard settings:
Home: \033[4~
End: \033[1~
PageUp: \033[5~
PageDown: \033[6~
To write \033 just press ESC button, for [ it’s MAJ+alt+5 and finally for the ~ it’s alt+n
then do not forget to assign the default value to this particular settings format
update: or use iTerm


