Skip to content

Commit

Permalink
Merge branch 'master' into sync-shared-config
Browse files Browse the repository at this point in the history
  • Loading branch information
p-linnane authored Dec 7, 2024
2 parents b6b42c8 + 63a5e51 commit 43c33c0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ This tap allows you to alias your [Homebrew](https://brew.sh/) commands.
This works similar to the `alias` command:

# add aliases
$ brew alias up='update'
$ brew alias ug='upgrade'
$ brew alias i='install'

# print all aliases
$ brew alias

# print one alias
$ brew alias up
$ brew alias i

# use your aliases like any other command
$ brew i git
Expand All @@ -33,8 +33,8 @@ commands as well as `alias` and `unalias`).

All aliases are prefixed with `brew`, unless they start with `!` or `%`:

# 'brew up' -> 'brew update'
$ brew alias up=update
# 'brew ug' -> 'brew upgrade'
$ brew alias ug=upgrade

# 'brew status' -> 'git status'
$ brew alias status='!git status'
Expand Down
26 changes: 13 additions & 13 deletions cmd/alias.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@ class Alias < AbstractCommand

sig { override.void }
def run
arg = args.named.first
split_arg = arg.split("=", 2) if arg.present?
name = args.named.first
name, command = name.split("=", 2) if name.present?

Aliases.init

if args.edit?
if arg.blank?
if name.nil?
if args.edit?
Aliases.edit_all
elsif /.=./.match?(arg)
Aliases.add(*split_arg)
Aliases.edit(split_arg.first)
else
Aliases.edit arg
Aliases.show
end
elsif command.nil?
if args.edit?
Aliases.edit name
else
Aliases.show name
end
elsif /.=./.match?(arg)
Aliases.add(*split_arg)
elsif arg.present?
Aliases.show arg
else
Aliases.show
Aliases.add name, command
Aliases.edit name if args.edit?
end
end
end
Expand Down
5 changes: 3 additions & 2 deletions lib/aliases.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ module Aliases
path
end.freeze
RESERVED = (
Commands::HOMEBREW_INTERNAL_COMMAND_ALIASES.keys +
Dir["#{HOMEBREW_LIBRARY_PATH}/cmd/*.rb"].map { |cmd| File.basename(cmd, ".rb") } +
Commands.internal_commands +
Commands.internal_developer_commands +
Commands.internal_commands_aliases +
%w[alias unalias]
).freeze

Expand Down

0 comments on commit 43c33c0

Please sign in to comment.