module Aliasing

Constants

VERSION

Public Class Methods

make_alias(name, command, location) click to toggle source
# File lib/aliasing.rb, line 7
def make_alias(name, command, location)
  existing_alias = verify_uniqueness_of name
  return puts "Error: #{name} is already a bash alias name for #{existing_alias}" if existing_alias

  %x[echo 'alias #{name}="#{command}"' >> #{location}]
end
verify_uniqueness_of(alias_name) click to toggle source
# File lib/aliasing.rb, line 14
def verify_uniqueness_of(alias_name)
  alias_list = %x[source ~/.profile && source ~/.bash_profile && alias].split "\n"
  aliases = {}
  alias_list.each { |a|
    match = a.match(/(.*)=(.*)/)
    aliases[match[1]] = match[2]
  }
  return aliases[alias_name]
end