You are not logged in.

#1 2019-08-02 16:01:17

drisc
Member
Registered: 2019-08-02
Posts: 2

st terminal not allowing use of HOME and END

I recently decided to give st a try, things went well until I tried to get HOME and END to work.

Both work properly inside xterm and termite (both terms use "\e[H" & "\e[F" escape sequences), but for some reason st uses "\e[4~" for END. I've been able to make them work in zsh using bindkey but in emacs HOME spits out 'C-u 7-' and END spits out 'M-[ f'.

I'm at a bit of a loss here, is there a patch for st that I can apply? I couldn't find one on the suckless site.

Offline

#2 2019-08-02 17:41:47

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,645

Re: st terminal not allowing use of HOME and END

Offline

#3 2019-08-02 17:51:47

drisc
Member
Registered: 2019-08-02
Posts: 2

Re: st terminal not allowing use of HOME and END

Yep, that’s where I got the ZSH fix from. I’ve tried modifying terminfo, checked /etc/inputrc and I’m not setting anything $TERM in my configs.

The termname is ‘st-256color’, you can set it in config.h when building st but even setting that to different things didn’t help.

Offline

#4 2019-08-02 18:36:15

sevendogs
Member
From: Texas
Registered: 2016-01-24
Posts: 201

Re: st terminal not allowing use of HOME and END

Not sure if this link is of use: https://git.suckless.org/st/file/FAQ.html It mentions home and end keys and a fix for zsh.


"Give a man a truth and he will think for a day. Teach a man to reason and he will think for a lifetime"

Offline

#5 2019-11-03 16:54:25

AlgoJerViA
Member
Registered: 2014-08-06
Posts: 22

Re: st terminal not allowing use of HOME and END

I learned to live with not having the home and end key with st and zsh. But today I felt that enough was enough. smile
Adding the following lines to ~/.zshrc finally solved the problem. (Taken from https://wiki.archlinux.org/index.php/Zsh#Key_bindings)

# create a zkbd compatible hash;
# to add other keys to this hash, see: man 5 terminfo
typeset -g -A key

key[Home]="${terminfo[khome]}"
key[End]="${terminfo[kend]}"
key[Insert]="${terminfo[kich1]}"
key[Backspace]="${terminfo[kbs]}"
key[Delete]="${terminfo[kdch1]}"
key[Up]="${terminfo[kcuu1]}"
key[Down]="${terminfo[kcud1]}"
key[Left]="${terminfo[kcub1]}"
key[Right]="${terminfo[kcuf1]}"
key[PageUp]="${terminfo[kpp]}"
key[PageDown]="${terminfo[knp]}"
key[ShiftTab]="${terminfo[kcbt]}"

# setup key accordingly
[[ -n "${key[Home]}"      ]] && bindkey -- "${key[Home]}"      beginning-of-line
[[ -n "${key[End]}"       ]] && bindkey -- "${key[End]}"       end-of-line
[[ -n "${key[Insert]}"    ]] && bindkey -- "${key[Insert]}"    overwrite-mode
[[ -n "${key[Backspace]}" ]] && bindkey -- "${key[Backspace]}" backward-delete-char
[[ -n "${key[Delete]}"    ]] && bindkey -- "${key[Delete]}"    delete-char
[[ -n "${key[Up]}"        ]] && bindkey -- "${key[Up]}"        up-line-or-history
[[ -n "${key[Down]}"      ]] && bindkey -- "${key[Down]}"      down-line-or-history
[[ -n "${key[Left]}"      ]] && bindkey -- "${key[Left]}"      backward-char
[[ -n "${key[Right]}"     ]] && bindkey -- "${key[Right]}"     forward-char
[[ -n "${key[PageUp]}"    ]] && bindkey -- "${key[PageUp]}"    beginning-of-buffer-or-history
[[ -n "${key[PageDown]}"  ]] && bindkey -- "${key[PageDown]}"  end-of-buffer-or-history
[[ -n "${key[ShiftTab]}"  ]] && bindkey -- "${key[ShiftTab]}"  reverse-menu-complete

# Finally, make sure the terminal is in application mode, when zle is
# active. Only then are the values from $terminfo valid.
if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then
	autoload -Uz add-zle-hook-widget
	function zle_application_mode_start {
		echoti smkx
	}
	function zle_application_mode_stop {
		echoti rmkx
	}
	add-zle-hook-widget -Uz zle-line-init zle_application_mode_start
	add-zle-hook-widget -Uz zle-line-finish zle_application_mode_stop
fi

//Algojervia

Offline

Board footer

Powered by FluxBB