Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to bash config code #486

Open
norbusan opened this issue Apr 17, 2023 · 3 comments
Open

Improvements to bash config code #486

norbusan opened this issue Apr 17, 2023 · 3 comments
Assignees

Comments

@norbusan
Copy link

Deciding upfront whether the kernel supports TIOCSTI or not might be difficult, so what about using this as bash init code?

####
# hstr configuration
alias hh=hstr                    # hh to be alias for hstr
export HSTR_CONFIG=hicolor       # get more colors
shopt -s histappend              # append new history items to .bash_history
export HISTCONTROL=ignorespace   # leading space hides commands from history
export HISTFILESIZE=10000        # increase history file size (default is 500)
export HISTSIZE=${HISTFILESIZE}  # increase history size (default is 500)

if [ -r /proc/sys/dev/tty/legacy_tiocsti ] ; then
  LEGACY_TIOCSTI=`cat /proc/sys/dev/tty/legacy_tiocsti`
else
  LEGACY_TIOCSTI=0
fi
if [ $LEGACY_TIOCSTI = 0 ] ; then
  function hstrnotiocsti {
    { HSTR_OUT="$( { </dev/tty hstr ${READLINE_LINE}; } 2>&1 1>&3 3>&- )"; } 3>&1;
    READLINE_LINE="$(hstr ${READLINE_LINE})"
    READLINE_POINT=${#READLINE_LINE}
  }
  # if this is interactive shell, then bind hstr to Ctrl-r (for Vi mode check doc)
  if [[ $- =~ .*i.* ]]; then bind -x '""hstrnotiocsti"'; fi
  export HSTR_TIOCSTI=n
else
  # Optionally add the following lines to ~/.bashrc if TIOCSTI is supported by your OS:
  # if this is interactive shell, then bind hstr to Ctrl-r (for Vi mode check doc)
  if [[ $- =~ .*i.* ]]; then bind '"\C-r": "\C-a hstr -- \C-j"'; fi
fi
@dvorka dvorka self-assigned this Apr 18, 2023
@dvorka dvorka added this to the 3.1 Pipe and pattern editor milestone Apr 18, 2023
@dvorka
Copy link
Owner

dvorka commented Apr 18, 2023

@norbusan It makes sense - you are right! I like it and I will update the configuration code in the upcoming release. Thanks!

@leapfog
Copy link

leapfog commented Apr 18, 2023

I might be wrong, but shouldn't

{ HSTR_OUT="$( { </dev/tty hstr ${READLINE_LINE}; } 2>&1 1>&3 3>&- )"; } 3>&1;
READLINE_LINE="$(hstr ${READLINE_LINE})"

rather be

{ READLINE_LINE="$( { </dev/tty hstr ${READLINE_LINE}; } 2>&1 1>&3 3>&- )"; } 3>&1;

@norbusan
Copy link
Author

@norbusan It makes sense - you are right! I like it and I will update the configuration code in the upcoming release. Thanks!

Thanks, good to know.

And thanks for all your work on this, much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants