Skip to content

Instantly share code, notes, and snippets.

@joaociocca
Last active March 14, 2023 14:21
Show Gist options
  • Save joaociocca/ea45cc2926a48a5483546916f89b863f to your computer and use it in GitHub Desktop.
Save joaociocca/ea45cc2926a48a5483546916f89b863f to your computer and use it in GitHub Desktop.
Little snippet to grab ruby's readline for evil-winrm
readline_evilwinrm() {
if [[ $(command -v evil-winrm) ]]; then
if [[ ! $(dpkg-query -l libreadline-dev) ]]; then
sudo apt install libreadline-dev -y
fi
ruby_version=$(ruby --version | awk -F'[ p]' '{print $2}')
ruby_mid=${ruby_version/%.[0-9]/}
wget https://ftp.ruby-lang.org/pub/ruby/${ruby_mid}/ruby-${ruby_version}.tar.gz &>/dev/null
tar -xf "ruby-${ruby_version}.tar.gz"
curdir="$PWD"
#shellcheck disable=SC2164
cd "ruby-${ruby_version}/ext/readline"
ruby ./extconf.rb &>/dev/null
make &>/dev/null
sudo cp "/usr/lib/x86_64-linux-gnu/ruby/${ruby_mid}.0/readline.so" "/usr/lib/x86_64-linux-gnu/ruby/${ruby_mid}.0/readline.so.bk"
sudo cp -f readline.so "/usr/lib/x86_64-linux-gnu/ruby/${ruby_mid}.0/readline.so"
#shellcheck disable=SC2164
cd "$curdir"
#shellcheck disable=SC2317
rm -rf "ruby-*"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment