From fd9bb503e97236de9a8946e05623a9a4797deb56 Mon Sep 17 00:00:00 2001 From: Craig Morton Date: Wed, 12 Sep 2018 13:59:03 +0100 Subject: [PATCH 01/12] Add awesome print for IRB to format output nicely --- mac | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mac b/mac index ea6c463aa..a352778a2 100755 --- a/mac +++ b/mac @@ -187,6 +187,16 @@ rbenv rehash fancy_echo "Skipping rdoc generation when we install a gem" echo 'gem: --no-rdoc --no-ri' >> ~/.gemrc +fancy_echo "Installing and configuring Awesome Print for IRB" +gem install awesome_print +if [ ! -f "$HOME/.irbrc" ]; then + touch "$HOME/.irbrc" +fi +cat > "$HOME/.irbrc" << EOM +require "awesome_print" +AwesomePrint.irb! +EOM + if [ -f "$HOME/.laptop.local" ]; then fancy_echo "Running your customizations from ~/.laptop.local ..." # shellcheck disable=SC1090 From a8f87491d5435934a22b0202b7bde6f690fbba13 Mon Sep 17 00:00:00 2001 From: Craig Morton Date: Wed, 12 Sep 2018 16:59:20 +0100 Subject: [PATCH 02/12] Add awesome_print config --- mac | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/mac b/mac index a352778a2..becd66d8d 100755 --- a/mac +++ b/mac @@ -196,6 +196,28 @@ cat > "$HOME/.irbrc" << EOM require "awesome_print" AwesomePrint.irb! EOM +if [ ! -f "$HOME/.aprc" ]; then + touch "$HOME/.aprc" +fi +cat > "$HOME/.aprc" << EOM +AwesomePrint.defaults = { + index: false, + indent: 2, + sort_vars: false, + color: { + string: :cyanish, + symbol: :purple, + array: :white, + hash: :purpleish, + trueclass: :green, + falseclass: :red, + nilclass: :redish, + class: :yellow, + integer: :blue, + float: :blueish + } +} +EOM if [ -f "$HOME/.laptop.local" ]; then fancy_echo "Running your customizations from ~/.laptop.local ..." From edf3e63168f1607ca25bf578223cf4fd89a4af1c Mon Sep 17 00:00:00 2001 From: Craig Morton Date: Wed, 12 Sep 2018 17:02:51 +0100 Subject: [PATCH 03/12] Add irb autocompletion to .irbrc --- mac | 1 + 1 file changed, 1 insertion(+) diff --git a/mac b/mac index becd66d8d..2b016fd74 100755 --- a/mac +++ b/mac @@ -195,6 +195,7 @@ fi cat > "$HOME/.irbrc" << EOM require "awesome_print" AwesomePrint.irb! +require 'irb/completion' EOM if [ ! -f "$HOME/.aprc" ]; then touch "$HOME/.aprc" From 0d86c698d2f365438825ffbfa7ef69c07ece0d96 Mon Sep 17 00:00:00 2001 From: Craig Morton Date: Wed, 12 Sep 2018 17:03:37 +0100 Subject: [PATCH 04/12] Add auto-indentation within irb to .irbrc --- mac | 1 + 1 file changed, 1 insertion(+) diff --git a/mac b/mac index 2b016fd74..d949345a4 100755 --- a/mac +++ b/mac @@ -196,6 +196,7 @@ cat > "$HOME/.irbrc" << EOM require "awesome_print" AwesomePrint.irb! require 'irb/completion' +IRB.conf[:AUTO_INDENT] = true EOM if [ ! -f "$HOME/.aprc" ]; then touch "$HOME/.aprc" From f8c8d4cd6debf07405ef455d5a4b0f76c263c64c Mon Sep 17 00:00:00 2001 From: Craig Morton Date: Wed, 12 Sep 2018 17:04:19 +0100 Subject: [PATCH 05/12] Add irb history saving to .irbrc This enables accessing history with the up cursor key even between irb sessions --- mac | 1 + 1 file changed, 1 insertion(+) diff --git a/mac b/mac index d949345a4..36a0b2fc0 100755 --- a/mac +++ b/mac @@ -197,6 +197,7 @@ require "awesome_print" AwesomePrint.irb! require 'irb/completion' IRB.conf[:AUTO_INDENT] = true +IRB.conf[:SAVE_HISTORY] = 1000 EOM if [ ! -f "$HOME/.aprc" ]; then touch "$HOME/.aprc" From 7247c3cc48998dbd0b153fbffa6b12d88c18853a Mon Sep 17 00:00:00 2001 From: Craig Morton Date: Wed, 12 Sep 2018 17:05:26 +0100 Subject: [PATCH 06/12] Simplify irb prompt with custom setting in .irbrc --- mac | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mac b/mac index 36a0b2fc0..a558fedf5 100755 --- a/mac +++ b/mac @@ -198,6 +198,13 @@ AwesomePrint.irb! require 'irb/completion' IRB.conf[:AUTO_INDENT] = true IRB.conf[:SAVE_HISTORY] = 1000 +IRB.conf[:PROMPT][:CUSTOM] = { + :PROMPT_I => 'irb> ', + :PROMPT_S => 'irb>%l ', + :PROMPT_C => 'irb>> ', + :PROMPT_N => 'irb>> ' +} +IRB.conf[:PROMPT_MODE] = :CUSTOM EOM if [ ! -f "$HOME/.aprc" ]; then touch "$HOME/.aprc" From 8e727e8a9ec3baa5cea6fd38511e5a806ead560a Mon Sep 17 00:00:00 2001 From: Craig Morton Date: Wed, 12 Sep 2018 17:58:07 +0100 Subject: [PATCH 07/12] Remove condition around 'touch' commands I did this initially because the pre-existing code to create the ~/.zshrc file was wrapped in a condition checking for the existance of the file. However I don't see why this condition is necessary. `touch` will only update the accessed and modified timestamps on a file if it already exists, and in all cases we are modifying the files at this time. --- mac | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/mac b/mac index a558fedf5..18cb77845 100755 --- a/mac +++ b/mac @@ -189,9 +189,7 @@ echo 'gem: --no-rdoc --no-ri' >> ~/.gemrc fancy_echo "Installing and configuring Awesome Print for IRB" gem install awesome_print -if [ ! -f "$HOME/.irbrc" ]; then - touch "$HOME/.irbrc" -fi +touch "$HOME/.irbrc" cat > "$HOME/.irbrc" << EOM require "awesome_print" AwesomePrint.irb! @@ -206,9 +204,7 @@ IRB.conf[:PROMPT][:CUSTOM] = { } IRB.conf[:PROMPT_MODE] = :CUSTOM EOM -if [ ! -f "$HOME/.aprc" ]; then - touch "$HOME/.aprc" -fi +touch "$HOME/.aprc" cat > "$HOME/.aprc" << EOM AwesomePrint.defaults = { index: false, From 2b16fe937d39dfd93b97c4ce69f9c540d5526ff8 Mon Sep 17 00:00:00 2001 From: Craig Morton Date: Thu, 13 Sep 2018 14:45:03 +0100 Subject: [PATCH 08/12] Use existing gem install function to install AP --- mac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mac b/mac index 18cb77845..cbfd46624 100755 --- a/mac +++ b/mac @@ -188,7 +188,7 @@ fancy_echo "Skipping rdoc generation when we install a gem" echo 'gem: --no-rdoc --no-ri' >> ~/.gemrc fancy_echo "Installing and configuring Awesome Print for IRB" -gem install awesome_print +gem_install_or_update 'awesome_print' touch "$HOME/.irbrc" cat > "$HOME/.irbrc" << EOM require "awesome_print" From fce6a768fd803ffc0c8b66767e1d4bff4491b0b3 Mon Sep 17 00:00:00 2001 From: Craig Morton Date: Mon, 28 Jan 2019 13:39:12 +0000 Subject: [PATCH 09/12] Append to, don't replace, irb config files --- mac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mac b/mac index cbfd46624..c4e1f43a0 100755 --- a/mac +++ b/mac @@ -190,7 +190,7 @@ echo 'gem: --no-rdoc --no-ri' >> ~/.gemrc fancy_echo "Installing and configuring Awesome Print for IRB" gem_install_or_update 'awesome_print' touch "$HOME/.irbrc" -cat > "$HOME/.irbrc" << EOM +cat >> "$HOME/.irbrc" << EOM require "awesome_print" AwesomePrint.irb! require 'irb/completion' @@ -205,7 +205,7 @@ IRB.conf[:PROMPT][:CUSTOM] = { IRB.conf[:PROMPT_MODE] = :CUSTOM EOM touch "$HOME/.aprc" -cat > "$HOME/.aprc" << EOM +cat >> "$HOME/.aprc" << EOM AwesomePrint.defaults = { index: false, indent: 2, From 0c88e8093d82d049450734f70543b1f045690b71 Mon Sep 17 00:00:00 2001 From: Craig Morton Date: Mon, 28 Jan 2019 13:40:04 +0000 Subject: [PATCH 10/12] Remove unnecessary `touch` commands --- mac | 2 -- 1 file changed, 2 deletions(-) diff --git a/mac b/mac index c4e1f43a0..3e38f25a0 100755 --- a/mac +++ b/mac @@ -189,7 +189,6 @@ echo 'gem: --no-rdoc --no-ri' >> ~/.gemrc fancy_echo "Installing and configuring Awesome Print for IRB" gem_install_or_update 'awesome_print' -touch "$HOME/.irbrc" cat >> "$HOME/.irbrc" << EOM require "awesome_print" AwesomePrint.irb! @@ -204,7 +203,6 @@ IRB.conf[:PROMPT][:CUSTOM] = { } IRB.conf[:PROMPT_MODE] = :CUSTOM EOM -touch "$HOME/.aprc" cat >> "$HOME/.aprc" << EOM AwesomePrint.defaults = { index: false, From 9bb4f37a4c61537d99da8cb348900f828cd4b1be Mon Sep 17 00:00:00 2001 From: Craig Morton Date: Wed, 30 Jan 2019 10:37:01 +0000 Subject: [PATCH 11/12] Add comments to (ap|irb)rc in case we're appending to existing configs --- mac | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mac b/mac index 3e38f25a0..e1314a77d 100755 --- a/mac +++ b/mac @@ -190,6 +190,7 @@ echo 'gem: --no-rdoc --no-ri' >> ~/.gemrc fancy_echo "Installing and configuring Awesome Print for IRB" gem_install_or_update 'awesome_print' cat >> "$HOME/.irbrc" << EOM +# CodeClan deafault configuration for IRB require "awesome_print" AwesomePrint.irb! require 'irb/completion' @@ -204,6 +205,8 @@ IRB.conf[:PROMPT][:CUSTOM] = { IRB.conf[:PROMPT_MODE] = :CUSTOM EOM cat >> "$HOME/.aprc" << EOM +# CodeClan deafault configuration for Awesome Print (Ruby / IRB) +# Find ptions for customisation here: https://github.com/awesome-print/awesome_print#usage AwesomePrint.defaults = { index: false, indent: 2, From 879e3263575ead6a247a901bc213ff9c7619823f Mon Sep 17 00:00:00 2001 From: Craig Morton Date: Wed, 30 Jan 2019 10:37:53 +0000 Subject: [PATCH 12/12] Consistent quote style in generated .irbrc --- mac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mac b/mac index e1314a77d..6449c330e 100755 --- a/mac +++ b/mac @@ -191,7 +191,7 @@ fancy_echo "Installing and configuring Awesome Print for IRB" gem_install_or_update 'awesome_print' cat >> "$HOME/.irbrc" << EOM # CodeClan deafault configuration for IRB -require "awesome_print" +require 'awesome_print' AwesomePrint.irb! require 'irb/completion' IRB.conf[:AUTO_INDENT] = true