bin/setup.sh in getch-0.0.1 vs bin/setup.sh in getch-0.0.2
- old
+ new
@@ -24,12 +24,11 @@
if hash ruby 2>/dev/null ; then
echo "Ruby $(ruby -v | awk '{print $2}') found"
else
echo "Install ruby"
if hash pacman 2>/dev/null ; then
- pacman -Syy
- pacman -S --needed ruby
+ pacman -Syy libyaml ruby ruby-irb ruby-reline rubygems
elif hash emerge 2>/dev/null ; then
emerge -av dev-lang/ruby
elif hash apt-get 2>/dev/null ; then
apt-get install ruby
else
@@ -37,21 +36,39 @@
fi
fi
}
get_getch() {
- cd /tmp
- [ -f ./getch.tar.gz ] && rm ./getch.tar.gz
- [ -d ./getch-master ] && rm -rf ./getch-master
+ if hash gem 2>/dev/null ; then
+ gem install getch
+ getch -h
+ else
+ cd /tmp
+ [ -f ./getch.tar.gz ] && rm ./getch.tar.gz
+ [ -d ./getch-master ] && rm -rf ./getch-master
- curl -s -L -o getch.tar.gz https://github.com/szorfein/getch/archive/master.tar.gz
- tar xzf getch.tar.gz
+ curl -s -L -o getch.tar.gz https://github.com/szorfein/getch/archive/master.tar.gz
+ tar xzf getch.tar.gz \
+ && cd $DIR \
+ && ruby -I lib bin/getch -h
+ fi
}
+set_shell() {
+ your_shell=~/.bashrc
+ [ -f ~/.zshrc ] && your_shell=~/.zshrc
+
+ [ -f "$your_shell" ] && {
+ if ! grep -q ".gem/ruby/[0-9.]*/bin" "$your_shell" ; then
+ echo "export PATH=\$PATH:$(ruby -e 'puts Gem.user_dir')/bin" >> "$your_shell"
+ fi
+ . "$your_shell"
+ }
+}
+
main() {
- get_getch
search_ruby
- cd $DIR \
- && ruby -I lib bin/getch
+ set_shell
+ get_getch
}
main "$@"