homebrew / homebrew-aliases Goto Github PK
View Code? Open in Web Editor NEW:arrow_right: Aliases for Homebrew
License: BSD 2-Clause "Simplified" License
:arrow_right: Aliases for Homebrew
License: BSD 2-Clause "Simplified" License
--force
and the issue is still present.brew update-reset && brew update
and retried my command.brew doctor
, fixed as many issues as possible and retried my command.brew tap "homebrew/aliases"
brew alias all='update;brew upgrade;brew cask upgrade;brew cleanup;brew cask cleanup;brew doctor'
Command works as expected, creating the appropriate alias, with no functional issue. But, the command returns the following:
Warning: Calling <<-EOS.undent is deprecated!
Use <<~EOS instead.
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-aliases/cmd/brew-alias.rb:75:in `write'
Please report this to the homebrew/aliases tap!
Warning: Calling <<-EOS.undent is deprecated!
Use <<~EOS instead.
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-aliases/cmd/brew-alias.rb:95:in `block in write'
Please report this to the homebrew/aliases tap!
--verbose --debug
/usr/local/Homebrew/Library/Homebrew/brew.rb:107:in `exit'
/usr/local/Homebrew/Library/Homebrew/brew.rb:107:in `<main>'
brew cask doctor
Your system is ready to brew.
homebrew-aliases seems to support editing alias files (there is the brew alias --edit
command). But, some edits that result in otherwise working scripts can confuse the alias
command leading to nonsensical output, useless files written to disk, and with the addition of the user deleting the symlink at $HOMEBREW_PREFIX/bin/brew-*
, causes brew alias
to overwrite user created alias scripts with corrupted data.
The following is shell output demonstrating all of the issues mentioned above. For the sake of brevity I didn't include the alias scripts, but they should be reproducible bit-for-bit using the brew alias
and sed
commands below.
I'm not saying that these exact scripts are useful, they aren't, but rather these are the minimal steps to reproduce issues I had with actual scripts I wrote.
~ $ # get a clean working state
~ $ rm -rf .brew-aliases/
~ $ ls /opt/homebrew/bin/brew-*
ls: /opt/homebrew/bin/brew-*: No such file or directory
~ $ # create aliases
~ $ brew alias hello='!echo hello world'
~ $ brew alias hello2='!echo hello again'
~ $ # edit aliases
# this edits the `# alias:` comment at the top
~ $ sed -i '' 's/alias:.*$/better not edit this/' ~/.brew-aliases/hello
# this wraps the `echo` line in an `if` statement
~ $ sed -i '' 's/\(^echo.*$\)/if true; then\n \1\nfi/' ~/.brew-aliases/hello2
~ $ # get checksums for reference
~ $ md5 .brew-aliases/*
MD5 (.brew-aliases/hello) = 5cf77855dae72c39996d8519b562cd39
MD5 (.brew-aliases/hello2) = afc0805389b434f0526959e94937370e
~ $ brew alias
brew alias # better not edit this='!echo hello world'
brew alias hello2='!if true; then'
~ $ # that output is odd, but the md5 is okay
~ $ # but there is another file?
~ $ md5 .brew-aliases/*
MD5 (.brew-aliases/__better_not_edit_this) = 17194e87812aac6f4e5be6cb8ec95d6c
MD5 (.brew-aliases/hello) = 5cf77855dae72c39996d8519b562cd39
MD5 (.brew-aliases/hello2) = afc0805389b434f0526959e94937370e
~ $ ls -1 /opt/homebrew/bin/brew-*
/opt/homebrew/bin/brew-# better not edit this
/opt/homebrew/bin/brew-hello
/opt/homebrew/bin/brew-hello2
~ $ # remove the odd file and all the symlinks
~ $ rm /opt/homebrew/bin/brew-*; rm ~/.brew-aliases/__better_not_edit_this
~ $ # run alias command again to regen symlinks
~ $ brew alias
brew alias # better not edit this='!echo hello world'
brew alias hello2='!if true; then'
~ $ md5 .brew-aliases/*
MD5 (.brew-aliases/__better_not_edit_this) = 17194e87812aac6f4e5be6cb8ec95d6c
MD5 (.brew-aliases/hello) = 5cf77855dae72c39996d8519b562cd39
MD5 (.brew-aliases/hello2) = 05e54836d8513b4d67ddc757b6734504
~ $ # ^ recreated the bad file, and now hello2 is corrupted
It's pretty reasonable if these types of edits aren't supported, but brew alias
should fail a little more gracefully if it can't parse a script. I found all of this by accident, and in one case was lucky that my dotfiles are in a git repo.
Tried to create a simple alias with the "!" prefix, like so:
bash-4.4$ brew alias toast="!echo I like toast"
bash: !echo: event not found
The standard usage seems to work though.
...as line 9 always fails.
homebrew-aliases/lib/aliases.rb
Lines 8 to 12 in da6f87a
Changing it to
Pathname.new("~/.config/brew-aliases").expand_path
should fix it, but then the latter condition ("~/.brew-aliases"
) is never reached.
Great to see that you have such a useful tool!
I am thinking about why not have a tool for homebrew-cask command line? Which does the same thing as homebrew-aliases
but the command starts with cask
. How do you like the idea?
Running brew alias -anything="12d"
gives traceback of
/usr/local/Library/brew.rb:101:in `exit'
/usr/local/Library/brew.rb:101:in `<main>'
The alias still works, and the exit code is 0. From testing, it looks like it needs the alias to start with -
, and the third character in the command needs to be a d
. I have no clue why this happens...
(I found this by running brew alias -Syu="update && brew info"
)
That's what I get when running brew commands
after latest updates.
Also, brew tap-info
tells:
λ brew tap-info homebrew/aliases
homebrew/aliases: unpinned, 3 commands <------------ 3 commands?
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-aliases (194 files, 125.6KB)
From: https://github.com/Homebrew/homebrew-aliases
I have aliases I find generally useful like https://github.com/texastoland/dotfiles/blob/main/.config/brew-aliases/tree or a version of bundle dump
that adds tree
's output in a frontmatter. Is it possible to share them via a tap or something?
I understand the backwards compatibility issue. It'd be nice to at least be able to configure the directory. Generally I'd expect it in .config/brew-aliases
.
brew alias
command results in Error: Is a directory @ rb_sysopen - ${HOME}/.brew-aliases
I just followed the readme:
❯ brew alias status='!git status'
❯ brew alias status
brew alias status='!git status'
❯ brew unalias status
Error: undefined method `named' for ["status"]:Array
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-aliases/cmd/unalias.rb:22:in `unalias'
/usr/local/Homebrew/Library/Homebrew/brew.rb:110:in `<main>'
As title.
I have a fresh install of homebrew and homebrew-aliases on macos catalina and none of the aliases I created take effect.
$ brew --version
Homebrew 3.0.5-62-gacfe9d2
Homebrew/homebrew-core (git revision ee7e17270e; last commit 2021-03-15)
Homebrew/homebrew-cask (git revision 86545bc466; last commit 2021-03-15)
$ brew tap --debug --verbose
adoptopenjdk/openjdk
aws/tap
chrokh/tap
colindean/fonts-nonfree
homebrew/aliases
homebrew/cask
homebrew/cask-fonts
homebrew/cask-versions
homebrew/command-not-found
homebrew/core
jmespath/jmespath
minio/stable
paulfitz/data
rbenv/tap
saulpw/vd
srkomodo/tap
universal-ctags/universal-ctags
$ brew alias
brew alias upg='upgrade'
brew alias ci='cask install'
brew alias i='install'
brew alias old='outdated'
brew alias cold='outdated --cask'
brew alias cupg='cask upgrade'
$ brew old
Error: Unknown command: old
$ type -a brew
brew is /usr/local/bin/brew
brew is /usr/local/bin/brew
$ which brew
/usr/local/bin/brew
$ echo $SHELL
/usr/local/bin/fish
$ ls ~/.brew-aliases
ci cold cupg i old upg
I am not sure what the issue is, but if there is any more information I can provide to help diagnose the issue please reach out.
$ brew install --help
brew install [--debug] [--env=std|super] [--ignore-dependencies] [--only-dependencies] [--cc=compiler] [--build-from-source] [--devel|--HEAD] [--keep-tmp] formula:
Install formula.
[…]
$ brew alias yolo=install
$ brew yolo --help
Warning: No help text in: /usr/local/bin/brew-yolo
Example usage:
brew search [TEXT|/REGEX/]
brew (info|home|options) [FORMULA...]
[…]
For more exposure of a cool idea 😀
unalias
always says the alias doesn't exist.
alias --edit
always says the alias already exists (which is true, but shouldn't be an error).
$ brew alias
brew alias overwrite='info %'
brew alias i='install'
$ brew unalias overwrite
Error: 'brew overwrite' is not aliased to anything.
$ brew alias --edit overwrite
Error: 'brew overwrite' already exists. Sorry.
$ brew unalias i
Error: 'brew i' is not aliased to anything.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.