From f31c4876dc3ace821747cc81901526d95b56106a Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 7 Feb 2025 14:21:38 +0000 Subject: [PATCH] Deprecate tap `brew alias` and `brew unalias` still work as before, they just aren't in this tap any more. --- .github/dependabot.yml | 17 --- .github/workflows/actionlint.yml | 85 ----------- .github/workflows/stale-issues.yml | 82 ---------- .github/workflows/tests.yml | 19 --- .rubocop.yml | 230 ----------------------------- .ruby-version | 1 - LICENSE | 22 --- README.md | 71 +-------- cmd/.gitignore | 3 - cmd/alias.rb | 47 ------ cmd/alias.rbi | 11 -- cmd/unalias.rb | 24 --- lib/alias.rb | 97 ------------ lib/aliases.rb | 79 ---------- 14 files changed, 4 insertions(+), 784 deletions(-) delete mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/actionlint.yml delete mode 100644 .github/workflows/stale-issues.yml delete mode 100644 .github/workflows/tests.yml delete mode 100644 .rubocop.yml delete mode 100644 .ruby-version delete mode 100644 LICENSE delete mode 100644 cmd/.gitignore delete mode 100755 cmd/alias.rb delete mode 100644 cmd/alias.rbi delete mode 100755 cmd/unalias.rb delete mode 100644 lib/alias.rb delete mode 100644 lib/aliases.rb diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 75e3575..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,17 +0,0 @@ -# This file is synced from the `.github` repository, do not modify it directly. ---- -version: 2 -updates: -- package-ecosystem: github-actions - directory: "/" - schedule: - interval: weekly - allow: - - dependency-type: all - ignore: - - dependency-name: actions/stale - groups: - artifacts: - patterns: - - actions/*-artifact - diff --git a/.github/workflows/actionlint.yml b/.github/workflows/actionlint.yml deleted file mode 100644 index f25f165..0000000 --- a/.github/workflows/actionlint.yml +++ /dev/null @@ -1,85 +0,0 @@ -# This file is synced from the `.github` repository, do not modify it directly. -name: Actionlint - -on: - push: - branches: - - main - - master - pull_request: - merge_group: - -defaults: - run: - shell: bash -xeuo pipefail {0} - -concurrency: - group: "actionlint-${{ github.ref }}" - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - -env: - HOMEBREW_DEVELOPER: 1 - HOMEBREW_NO_AUTO_UPDATE: 1 - HOMEBREW_NO_ENV_HINTS: 1 - -permissions: {} - -jobs: - workflow_syntax: - if: github.repository_owner == 'Homebrew' - runs-on: ubuntu-latest - permissions: - contents: read - steps: - - name: Set up Homebrew - id: setup-homebrew - uses: Homebrew/actions/setup-homebrew@master - with: - core: false - cask: false - test-bot: false - - - name: Install tools - run: brew install actionlint shellcheck zizmor - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - persist-credentials: false - - - run: zizmor --format sarif . > results.sarif - - - name: Upload SARIF file - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 - with: - name: results.sarif - path: results.sarif - - - name: Set up actionlint - run: echo "::add-matcher::$(brew --repository)/.github/actionlint-matcher.json" - - - run: actionlint - - upload_sarif: - needs: workflow_syntax - # We want to always upload this even if `actionlint` failed. - # This is only available on public repositories. - if: > - always() && - !contains(fromJSON('["cancelled", "skipped"]'), needs.workflow_syntax.result) && - !github.event.repository.private - runs-on: ubuntu-latest - permissions: - contents: read - security-events: write - steps: - - name: Download SARIF file - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 - with: - name: results.sarif - path: results.sarif - - - name: Upload SARIF file - uses: github/codeql-action/upload-sarif@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8 - with: - sarif_file: results.sarif - category: zizmor diff --git a/.github/workflows/stale-issues.yml b/.github/workflows/stale-issues.yml deleted file mode 100644 index 608d2e6..0000000 --- a/.github/workflows/stale-issues.yml +++ /dev/null @@ -1,82 +0,0 @@ -# This file is synced from the `.github` repository, do not modify it directly. -name: Manage stale issues - -on: - push: - paths: - - .github/workflows/stale-issues.yml - branches-ignore: - - dependabot/** - schedule: - # Once every day at midnight UTC - - cron: "0 0 * * *" - issue_comment: - -permissions: {} - -defaults: - run: - shell: bash -xeuo pipefail {0} - -concurrency: - group: stale-issues - cancel-in-progress: ${{ github.event_name != 'issue_comment' }} - -jobs: - stale: - if: > - github.repository_owner == 'Homebrew' && ( - github.event_name != 'issue_comment' || ( - contains(github.event.issue.labels.*.name, 'stale') || - contains(github.event.pull_request.labels.*.name, 'stale') - ) - ) - runs-on: ubuntu-latest - permissions: - contents: write - issues: write - pull-requests: write - steps: - - name: Mark/Close Stale Issues and Pull Requests - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - days-before-stale: 21 - days-before-close: 7 - stale-issue-message: > - This issue has been automatically marked as stale because it has not had - recent activity. It will be closed if no further activity occurs. - stale-pr-message: > - This pull request has been automatically marked as stale because it has not had - recent activity. It will be closed if no further activity occurs. - exempt-issue-labels: "gsoc-outreachy,help wanted,in progress" - exempt-pr-labels: "gsoc-outreachy,help wanted,in progress" - delete-branch: true - - bump-pr-stale: - if: > - github.repository_owner == 'Homebrew' && ( - github.event_name != 'issue_comment' || ( - contains(github.event.issue.labels.*.name, 'stale') || - contains(github.event.pull_request.labels.*.name, 'stale') - ) - ) - runs-on: ubuntu-latest - permissions: - contents: write - issues: write - pull-requests: write - steps: - - name: Mark/Close Stale `bump-formula-pr` and `bump-cask-pr` Pull Requests - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - days-before-stale: 2 - days-before-close: 1 - stale-pr-message: > - This pull request has been automatically marked as stale because it has not had - recent activity. It will be closed if no further activity occurs. To keep this - pull request open, add a `help wanted` or `in progress` label. - exempt-pr-labels: "help wanted,in progress" - any-of-labels: "bump-formula-pr,bump-cask-pr" - delete-branch: true diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 824ffb2..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: CI -on: - push: - branches: master - pull_request: - -jobs: - tests: - runs-on: macOS-latest - steps: - - name: Set up Homebrew - id: set-up-homebrew - uses: Homebrew/actions/setup-homebrew@master - - - run: brew test-bot --only-tap-syntax - - - run: brew alias ae='alias --edit' - - - run: brew alias diff --git a/.rubocop.yml b/.rubocop.yml deleted file mode 100644 index 625f3b0..0000000 --- a/.rubocop.yml +++ /dev/null @@ -1,230 +0,0 @@ -# This file is synced from `Homebrew/brew` by the `.github` repository, do not modify it directly. ---- -AllCops: - TargetRubyVersion: 3.3 - NewCops: enable - Include: - - "**/*.rbi" - Exclude: - - Homebrew/sorbet/rbi/{dsl,gems}/**/*.rbi - - Homebrew/bin/* - - Homebrew/vendor/**/* - - Taps/*/*/vendor/**/* - - "**/vendor/**/*" - SuggestExtensions: - rubocop-minitest: false -Layout/ArgumentAlignment: - Exclude: - - Taps/*/*/*.rb - - "/**/Formula/**/*.rb" - - "**/Formula/**/*.rb" -Layout/CaseIndentation: - EnforcedStyle: end -Layout/FirstArrayElementIndentation: - EnforcedStyle: consistent -Layout/FirstHashElementIndentation: - EnforcedStyle: consistent -Layout/EndAlignment: - EnforcedStyleAlignWith: start_of_line -Layout/HashAlignment: - EnforcedHashRocketStyle: table - EnforcedColonStyle: table -Layout/LeadingCommentSpace: - Exclude: - - Taps/*/*/cmd/*.rb -Layout/LineLength: - Max: 118 - AllowedPatterns: - - "#: " - - ' url "' - - ' mirror "' - - " plist_options " - - ' executable: "' - - ' font "' - - ' homepage "' - - ' name "' - - ' pkg "' - - ' pkgutil: "' - - " sha256 cellar: " - - " sha256 " - - "#{language}" - - "#{version." - - ' "/Library/Application Support/' - - "\"/Library/Caches/" - - "\"/Library/PreferencePanes/" - - ' "~/Library/Application Support/' - - "\"~/Library/Caches/" - - "\"~/Library/Containers" - - "\"~/Application Support" - - " was verified as official when first introduced to the cask" -Layout/SpaceAroundOperators: - Enabled: false -Layout/SpaceBeforeBrackets: - Exclude: - - "**/*_spec.rb" - - Taps/*/*/*.rb - - "/**/{Formula,Casks}/**/*.rb" - - "**/{Formula,Casks}/**/*.rb" -Lint/AmbiguousBlockAssociation: - Enabled: false -Lint/DuplicateBranch: - Exclude: - - Taps/*/*/*.rb - - "/**/{Formula,Casks}/**/*.rb" - - "**/{Formula,Casks}/**/*.rb" -Lint/ParenthesesAsGroupedExpression: - Exclude: - - Taps/*/*/*.rb - - "/**/Formula/**/*.rb" - - "**/Formula/**/*.rb" -Lint/UnusedMethodArgument: - AllowUnusedKeywordArguments: true -Metrics: - Enabled: false -Naming/BlockForwarding: - Enabled: false -Naming/FileName: - Regex: !ruby/regexp /^[\w\@\-\+\.]+(\.rb)?$/ -Naming/HeredocDelimiterNaming: - ForbiddenDelimiters: - - END, EOD, EOF -Naming/InclusiveLanguage: - CheckStrings: true - FlaggedTerms: - slave: - AllowedRegex: - - gitslave - - log_slave - - ssdb_slave - - var_slave - - patches/13_fix_scope_for_show_slave_status_data.patch -Naming/MethodName: - AllowedPatterns: - - "\\A(fetch_)?HEAD\\?\\Z" -Naming/MethodParameterName: - inherit_mode: - merge: - - AllowedNames -Naming/VariableNumber: - Enabled: false -Style/AndOr: - EnforcedStyle: always -Style/ArgumentsForwarding: - Enabled: false -Style/AutoResourceCleanup: - Enabled: true -Style/BarePercentLiterals: - EnforcedStyle: percent_q -Style/BlockDelimiters: - BracesRequiredMethods: - - sig -Style/ClassAndModuleChildren: - Exclude: - - "**/*.rbi" -Style/CollectionMethods: - Enabled: true -Style/DisableCopsWithinSourceCodeDirective: - Enabled: true - Include: - - Taps/*/*/*.rb - - "/**/{Formula,Casks}/**/*.rb" - - "**/{Formula,Casks}/**/*.rb" -Style/Documentation: - Exclude: - - Taps/**/* - - "/**/{Formula,Casks}/**/*.rb" - - "**/{Formula,Casks}/**/*.rb" - - "**/*.rbi" -Style/EmptyMethod: - Exclude: - - "**/*.rbi" -Style/FetchEnvVar: - Exclude: - - Taps/*/*/*.rb - - "/**/Formula/**/*.rb" - - "**/Formula/**/*.rb" -Style/FrozenStringLiteralComment: - EnforcedStyle: always - Exclude: - - Taps/*/*/*.rb - - "/**/{Formula,Casks}/**/*.rb" - - "**/{Formula,Casks}/**/*.rb" - - Homebrew/test/**/Casks/**/*.rb - - "**/*.rbi" - - "**/Brewfile" -Style/GuardClause: - Exclude: - - Taps/*/*/*.rb - - "/**/{Formula,Casks}/**/*.rb" - - "**/{Formula,Casks}/**/*.rb" -Style/HashAsLastArrayItem: - Exclude: - - Taps/*/*/*.rb - - "/**/Formula/**/*.rb" - - "**/Formula/**/*.rb" -Style/InverseMethods: - InverseMethods: - :blank?: :present? -Style/InvertibleUnlessCondition: - Enabled: true - InverseMethods: - :==: :!= - :zero?: - :blank?: :present? -Style/MutableConstant: - EnforcedStyle: strict -Style/NumericLiteralPrefix: - EnforcedOctalStyle: zero_only -Style/NumericLiterals: - MinDigits: 7 - Strict: true - Exclude: - - "**/Brewfile" -Style/OpenStructUse: - Exclude: - - Taps/**/* -Style/OptionalBooleanParameter: - AllowedMethods: - - respond_to? - - respond_to_missing? -Style/RedundantLineContinuation: - Enabled: false -Style/RescueStandardError: - EnforcedStyle: implicit -Style/ReturnNil: - Enabled: true -Style/StderrPuts: - Enabled: false -Style/StringConcatenation: - Exclude: - - Taps/*/*/*.rb - - "/**/{Formula,Casks}/**/*.rb" - - "**/{Formula,Casks}/**/*.rb" -Style/StringLiterals: - EnforcedStyle: double_quotes -Style/StringLiteralsInInterpolation: - EnforcedStyle: double_quotes -Style/StringMethods: - Enabled: true -Style/SuperWithArgsParentheses: - Enabled: false -Style/SymbolArray: - EnforcedStyle: brackets -Style/TernaryParentheses: - EnforcedStyle: require_parentheses_when_complex -Style/TopLevelMethodDefinition: - Enabled: true - Exclude: - - Taps/**/* -Style/TrailingCommaInArguments: - EnforcedStyleForMultiline: comma -Style/TrailingCommaInArrayLiteral: - EnforcedStyleForMultiline: comma -Style/TrailingCommaInHashLiteral: - EnforcedStyleForMultiline: comma -Style/UnlessLogicalOperators: - Enabled: true - EnforcedStyle: forbid_logical_operators -Style/WordArray: - MinSize: 4 - diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 86fb650..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -3.3.7 diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 0ad712f..0000000 --- a/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright 2015-2019 Homebrew contributors. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index 6340f10..ecfa396 100644 --- a/README.md +++ b/README.md @@ -1,70 +1,7 @@ -# Homebrew Aliases +# Homebrew Aliases (deprecated) -This tap allows you to alias your [Homebrew](https://brew.sh/) commands. +This tap allowed you to alias your [Homebrew](https://brew.sh/) commands. -## Install +It has now been moved into [Homebrew/brew](https://github.com/Homebrew/brew). - brew tap homebrew/aliases - -## Usage - -This works similar to the `alias` command: - - # add aliases - $ brew alias ug='upgrade' - $ brew alias i='install' - - # print all aliases - $ brew alias - - # print one alias - $ brew alias i - - # use your aliases like any other command - $ brew i git - - # remove an alias - $ brew unalias i - -**Note:** Some commands are reserved and can’t be aliased (Homebrew core -commands as well as `alias` and `unalias`). - -## Additional Features - -All aliases are prefixed with `brew`, unless they start with `!` or `%`: - - # 'brew ug' -> 'brew upgrade' - $ brew alias ug=upgrade - - # 'brew status' -> 'git status' - $ brew alias status='!git status' - -**Note:** You may need single-quotes to prevent your shell from -interpreting `!`, but `%` will work for both types. - - # Use shell expansion to preserve a local variable - # 'brew git status' -> '/path/to/my/git status' - $ mygit=/path/to/my/git - $ brew alias git="% $mygit" - -Aliases can include other aliases: - - $ brew alias show=info - $ brew alias print=show - $ brew print git # will run 'brew info git' - -Aliases can be opened in `$EDITOR` with the `--edit` flag. - - # Edit alias 'brew foo' - $ brew alias foo --edit - # Assign and edit alias 'brew foo' - $ brew alias foo=bar --edit - - # This works too - $ brew alias --edit foo - $ brew alias --edit foo=bar - - # Open all aliases in EDITOR - $ brew alias --edit - -**Note:** If the named alias doesn't exist it will be created. +`brew alias` and `brew unalias` still work as before, they just aren't in this tap any more. diff --git a/cmd/.gitignore b/cmd/.gitignore deleted file mode 100644 index 0d5404f..0000000 --- a/cmd/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*~ -.*.sw* -.DS_Store diff --git a/cmd/alias.rb b/cmd/alias.rb deleted file mode 100755 index 91cfe48..0000000 --- a/cmd/alias.rb +++ /dev/null @@ -1,47 +0,0 @@ -# typed: strict -# frozen_string_literal: true - -require "abstract_command" -require_relative "../lib/aliases" - -module Homebrew - module Cmd - class Alias < AbstractCommand - cmd_args do - usage_banner "`alias` [ ... | =]" - description <<~EOS - Show existing aliases. If no aliases are given, print the whole list. - EOS - switch "--edit", - description: "Edit aliases in a text editor. Either one or all aliases may be opened at once. " \ - "If the given alias doesn't exist it'll be pre-populated with a template." - named_args max: 1 - end - - sig { override.void } - def run - name = args.named.first - name, command = name.split("=", 2) if name.present? - - Aliases.init - - if name.nil? - if args.edit? - Aliases.edit_all - else - Aliases.show - end - elsif command.nil? - if args.edit? - Aliases.edit name - else - Aliases.show name - end - else - Aliases.add name, command - Aliases.edit name if args.edit? - end - end - end - end -end diff --git a/cmd/alias.rbi b/cmd/alias.rbi deleted file mode 100644 index ac5a171..0000000 --- a/cmd/alias.rbi +++ /dev/null @@ -1,11 +0,0 @@ -# typed: strict - -class Homebrew::Cmd::Alias - sig { returns(Homebrew::Cmd::Alias::Args) } - def args; end -end - -class Homebrew::Cmd::Alias::Args < Homebrew::CLI::Args - sig { returns(T::Boolean) } - def edit?; end -end diff --git a/cmd/unalias.rb b/cmd/unalias.rb deleted file mode 100755 index 9ae7a56..0000000 --- a/cmd/unalias.rb +++ /dev/null @@ -1,24 +0,0 @@ -# typed: strict -# frozen_string_literal: true - -require "abstract_command" -require_relative "../lib/aliases" - -module Homebrew - module Cmd - class Unalias < AbstractCommand - cmd_args do - description <<~EOS - Remove aliases. - EOS - named_args :alias, min: 1 - end - - sig { override.void } - def run - Aliases.init - args.named.each { |a| Aliases.remove a } - end - end - end -end diff --git a/lib/alias.rb b/lib/alias.rb deleted file mode 100644 index f095ec2..0000000 --- a/lib/alias.rb +++ /dev/null @@ -1,97 +0,0 @@ -# frozen_string_literal: true - -module Homebrew - module Aliases - class Alias - attr_accessor :name, :command - - def initialize(name, command = nil) - @name = name.strip - - command &&= if command.start_with? "!", "%" - command[1..] - else - "brew #{command}" - end - - @command = command - end - - def reserved? - RESERVED.include? name - end - - def cmd_exists? - path = which("brew-#{name}.rb") || which("brew-#{name}") - !path.nil? && path.realpath.parent != BASE_DIR - end - - def script - @script ||= Pathname.new("#{BASE_DIR}/#{name.gsub(/\W/, "_")}") - end - - def symlink - @symlink ||= Pathname.new("#{HOMEBREW_PREFIX}/bin/brew-#{name}") - end - - def valid_symlink? - symlink.realpath.parent == BASE_DIR - rescue NameError - false - end - - def link - FileUtils.rm symlink if File.symlink? symlink - FileUtils.ln_s script, symlink - end - - def write(opts = {}) - odie "'#{name}' is a reserved command. Sorry." if reserved? - odie "'brew #{name}' already exists. Sorry." if cmd_exists? - - return if !opts[:override] && script.exist? - - content = if command - <<~EOS - #: * `#{name}` [args...] - #: `brew #{name}` is an alias for `#{command}` - #{command} $* - EOS - else - <<~EOS - # - # This is a Homebrew alias script. It'll be called when the user - # types `brew #{name}`. Any remaining arguments are passed to - # this script. You can retrieve those with $*, or only the first - # one with $1. Please keep your script on one line. - - # TODO Replace the line below with your script - echo "Hello I'm brew alias "#{name}" and my args are:" $1 - EOS - end - - script.open("w") do |f| - f.write <<~EOS - #! #{`which bash`.chomp} - # alias: brew #{name} - #{content} - EOS - end - script.chmod 0744 - link - end - - def remove - odie "'brew #{name}' is not aliased to anything." if !symlink.exist? || !valid_symlink? - - script.unlink - symlink.unlink - end - - def edit - write(override: false) - exec_editor script.to_s - end - end - end -end diff --git a/lib/aliases.rb b/lib/aliases.rb deleted file mode 100644 index 40efa01..0000000 --- a/lib/aliases.rb +++ /dev/null @@ -1,79 +0,0 @@ -# frozen_string_literal: true - -require_relative "alias" - -module Homebrew - module Aliases - # Unix-Like systems store config in $HOME/.config whose location can be - # overridden by the XDG_CONFIG_HOME environment variable. Unfortunately - # Homebrew strictly filters environment variables in BuildEnvironment. - BASE_DIR = if (path = Pathname.new("~/.config/brew-aliases").expand_path).exist? || - (path = Pathname.new("~/.brew-aliases").expand_path).exist? - path.realpath - else - path - end.freeze - RESERVED = ( - Commands.internal_commands + - Commands.internal_developer_commands + - Commands.internal_commands_aliases + - %w[alias unalias] - ).freeze - - module_function - - def init - FileUtils.mkdir_p BASE_DIR - end - - def add(name, command) - new_alias = Alias.new(name, command) - odie "alias 'brew #{name}' already exists!" if new_alias.script.exist? - new_alias.write - end - - def remove(name) - Alias.new(name).remove - end - - def each(only) - Dir["#{BASE_DIR}/*"].each do |path| - next if path.end_with? "~" # skip Emacs-like backup files - next if File.directory?(path) - - _shebang, _meta, *lines = File.readlines(path) - target = File.basename(path) - next if !only.empty? && only.exclude?(target) - - lines.reject! { |line| line.start_with?("#") || line =~ /^\s*$/ } - cmd = lines.first.chomp - cmd.sub!(/ \$\*$/, "") - - if cmd.start_with? "brew " - cmd.sub!(/^brew /, "") - else - cmd = "!#{cmd}" - end - - yield target, cmd - end - end - - def show(*aliases) - each(aliases) do |target, cmd| - puts "brew alias #{target}='#{cmd}'" - existing_alias = Alias.new(target, cmd) - existing_alias.link unless existing_alias.symlink.exist? - end - end - - def edit(name, command = nil) - Alias.new(name, command).write unless command.nil? - Alias.new(name, command).edit - end - - def edit_all - exec_editor(*Dir[BASE_DIR]) - end - end -end