Sample Header Ad - 728x90

How to bind a keyboard shortcut in zsh to a program requiring stdin?

6 votes
2 answers
1359 views
This is a follow-up to [this question](https://unix.stackexchange.com/q/373795/63722) : I'm trying to create a keyboard shortcut for the terminal file manager [ranger](https://github.com/ranger/ranger) , in order to jump from the zsh prompt into the file manager with a single keystroke. I was following the linked answer, adding this to my .zshrc: run_ranger () { echo; ranger; zle redisplay } zle -N run_ranger bindkey '^f' run_ranger The key binding itself works, however ranger fails to start with Error: Must run ranger from terminal. I had a look at the [ranger code (Python)](https://github.com/ranger/ranger/blob/325f41e6a841ab1413020b9d2d86c3922d90f407/ranger/core/main.py#L137) and it performs the common check sys.stdin.isatty() to verify that is has a TTY stdin. How can I modify the zle widget so that stdin is properly set?
Asked by bluenote10 (301 rep)
Oct 13, 2018, 09:02 PM
Last activity: Aug 5, 2023, 10:10 AM