diff --git a/.bash/variables.sh b/.bash/variables.sh index 959d3e0f..8480d4c1 100644 --- a/.bash/variables.sh +++ b/.bash/variables.sh @@ -77,5 +77,6 @@ export STARSHIP_CONFIG="$XDG_CONFIG_HOME/starship/config.toml" export STARSHIP_CACHE="$XDG_CACHE_HOME/starship" export INPUTRC="$XDG_CONFIG_HOME/readline/inputrc" export RBENV_ROOT="$XDG_DATA_HOME/rbenv" +export IRBRC="$XDG_CONFIG_HOME/irb/irbrc" export GPG_TTY=$(tty) diff --git a/.zsh/variables.zsh b/.zsh/variables.zsh index b3c99a42..0504775c 100644 --- a/.zsh/variables.zsh +++ b/.zsh/variables.zsh @@ -85,5 +85,6 @@ export STARSHIP_CONFIG="$XDG_CONFIG_HOME/starship/config.toml" export STARSHIP_CACHE="$XDG_CACHE_HOME/starship" export INPUTRC="$XDG_CONFIG_HOME/readline/inputrc" export RBENV_ROOT="$XDG_DATA_HOME/rbenv" +export IRBRC="$XDG_CONFIG_HOME/irb/irbrc" export GPG_TTY=$(tty) diff --git a/bin/put_settings.sh b/bin/put_settings.sh index 5ff0ad29..9dd40178 100755 --- a/bin/put_settings.sh +++ b/bin/put_settings.sh @@ -36,7 +36,7 @@ if [ -d "$SETTINGS_PATH/.vim" ]; then ln -s "$SETTINGS_PATH/.vim" "$XDG_CONFIG_HOME/nvim" fi -for app in "git" "starship" "lsd" "sheldon" "bundle" "readline" "gem" "rspec" "tmux"; do +for app in "git" "starship" "lsd" "sheldon" "bundle" "readline" "gem" "irb" "rspec" "tmux"; do if [ -L "$XDG_CONFIG_HOME/$app" ]; then unlink "$XDG_CONFIG_HOME/$app" fi @@ -68,6 +68,10 @@ for app in "git" "starship" "lsd" "sheldon" "bundle" "readline" "gem" "rspec" "t fi done fi + + if [ "$app" = "irb" ] && [ ! -d "$XDG_DATA_HOME/$app" ]; then + mkdir --parents "$XDG_DATA_HOME/$app" + fi done unset -v app unset -v shell @@ -85,13 +89,6 @@ find "$SETTINGS_PATH"/.* -maxdepth 0 -type f -exec sh -c ' ln -s "$dot_file" "$HOME/$dot_filename" ' sh {} \; -if [ -L "$HOME/.irbrc" ]; then - unlink "$HOME/.irbrc" -fi -if [ -f "$GITHUB_REPOSITORIES_PATH/k0kubun/dotfiles/config/.irbrc" ]; then - ln -s "$GITHUB_REPOSITORIES_PATH/k0kubun/dotfiles/config/.irbrc" "$HOME/.irbrc" -fi - if [ -L /etc/my.cnf ]; then sudo unlink /etc/my.cnf fi diff --git a/config/irb/irbrc b/config/irb/irbrc new file mode 100644 index 00000000..41cb5a8e --- /dev/null +++ b/config/irb/irbrc @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +autoload :Base64, 'base64' +autoload :CGI, 'cgi' +autoload :CSV, 'csv' +autoload :Digest, 'digest' +autoload :ERB, 'erb' +autoload :FileUtils, 'fileutils' +autoload :JSON, 'json' +autoload :Pathname, 'pathname' +autoload :Psych, 'psych' +autoload :Ripper, 'ripper' +autoload :SecureRandom, 'securerandom' +autoload :Shellwords, 'shellwords' +autoload :StringIO, 'stringio' +autoload :URI, 'uri/generic' # `autoload :URI, 'uri'` breaks Rails +autoload :YAML, 'yaml' +autoload :Zlib, 'zlib' + +IRB.conf[:USE_AUTOCOMPLETE] = false +IRB.conf[:SAVE_HISTORY] = 1000 +IRB.conf[:HISTORY_FILE] = File.join(ENV['XDG_DATA_HOME'], 'irb', 'history') +if defined?(IRB::Color) # just for consistency + clear = "\e[0m" + bold = "\e[1m" + green = "\e[32m" + blue = "\e[34m" + cyan = "\e[36m" + IRB.conf[:PROMPT][:DEFAULT] = { + PROMPT_I: "#{cyan}#{bold}%N#{clear}(#{green}#{bold}%m#{clear})[#{blue}%02n#{clear}:%i]> ", + PROMPT_N: "#{cyan}#{bold}%N#{clear}(#{green}#{bold}%m#{clear})[#{blue}%02n#{clear}:%i]> ", + PROMPT_S: "#{cyan}#{bold}%N#{clear}(#{green}#{bold}%m#{clear})[#{blue}%02n#{clear}:%i]%l ", + PROMPT_C: "#{cyan}#{bold}%N#{clear}(#{green}#{bold}%m#{clear})[#{blue}%02n#{clear}:%i]* ", + RETURN: "=> %s\n", + } +end