-
-
Save ibrasho/148ad91839879b88395b10c69cd6dd07 to your computer and use it in GitHub Desktop.
Revisions
-
ibrasho revised this gist
Nov 5, 2020 . 1 changed file with 7 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -36,15 +36,9 @@ # # Configuration: # # 1. Drop this file in `~/.config/fish/conf.d/bundler-exec.fish` # # 2. Add `~/.config/fish/functions/fish_user_key_bindings.fish` with # these lines: # # function fish_user_key_bindings @@ -56,7 +50,7 @@ # (or just add the inner if/end block to that function if you're # already defining it). # # 3. This *effectively* puts your bundle's "bin" directory at the # start of `$PATH`, so you may as well actually put it there so # that completions and suggestions will also work. You can find # that path by going to a project directory that uses Bundler and @@ -68,6 +62,7 @@ # executed directly.) # # Author: Glenn Vanderburg <[email protected]> # Updated by: Ibrahim AshShohail <[email protected]> begin # Support Functions @@ -82,7 +77,7 @@ begin if test -f "$dir/Gemfile" -o -f "$dir/gems.rb" return end set dir (dirname $dir) end false end @@ -93,12 +88,12 @@ begin and _within-bundled-project # This version is slow but simple and safe. set -l bundle_path (bundle exec gem environment path) # This version is faster but complex and probably brittle. If # you're seeing flaky behavior around all of this, switch to the # slow version above and see if that fixes it. # set -l bundle_path (bundle config path | sed -e '/^Set /!d;s/^.*: "\(.*\)".*$/\1/') set -gx RUN_WITH_BUNDLER (command ls "$bundle_path/bin") else -
glv revised this gist
Sep 22, 2017 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -122,3 +122,5 @@ begin commandline -f execute end end _discover_bundle -
glv revised this gist
Sep 21, 2017 . 1 changed file with 23 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,30 +1,36 @@ # This sets up fish so that, if you type a command that should be # run using Bundler, it first automatically prepends "bundle exec" # to the command line buffer before executing it. Works for all # commands found in the "bin" directory of the current bundle. # # To override this behavior and run such a command without Bundler, # prefix with "command" (e.g., `command rake -T`) # # Pros (vs binstubs or aliases): # * automatically adjusts to bundle changes # * explicit (the command visible on your terminal and in your history is # "bundle exec whatever", and it's a nice reminder that Bundler magic is # happening with those commands) # # Cons: # * Might be surprising at first ("I didn't type that!") # * Slows down `cd` and other directory change operations a bit (to recompute # the `RUN_WITH_BUNDLER` environment variable) # * Only works if the first token on the command line needs to be run with # Bundler. (For example, if you try `env RAILS_ENV=test rake db:create`, # that won't work because `env` doesn't need to run under Bundler. But in # that very common case, I just use Rake's ability to take environment # overrides in *its* argument list instead: `rake RAILS_ENV=test db:create`.) # * Effectively puts a relative directory in your path (in fact, it works best # if you actually do that). This *can* open an attack vector for someone to # gain access to your machine, but this is generally not an issue if you # aren't root and are not sharing directories with other users. Plus, the # altered command line will at least help you notice if something unexpected # happened (such as a bundled executable shadowing the `ls` command). # # Deficiencies: # * If you work simultaneously in projects that use Bundler and other projects # that use a similar tool, you might want to have things set up to work # appropriately with both tools. Currently this is not implemented so as # to compose well with similar packages. # @@ -50,11 +56,16 @@ # (or just add the inner if/end block to that function if you're # already defining it). # # 4. This *effectively* puts your bundle's "bin" directory at the # start of `$PATH`, so you may as well actually put it there so # that completions and suggestions will also work. You can find # that path by going to a project directory that uses Bundler and # running `bundle config path`, and then append "/bin" to the # value that is displayed. I have Bundler configured to always # put the project bundle in `.bundle`, but YMMV. (Note: don't do # this step without steps 1-3, because the scripts in the bundle's # bin directory are not binstubs, so they won't load the bundle if # executed directly.) # # Author: Glenn Vanderburg <[email protected]> -
glv revised this gist
Sep 21, 2017 . 1 changed file with 20 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ # commands found in the "bin" directory of the current bundle. # # To override this behavior and run such a command without bundler, # prefix with "command" (e.g., `command rake -T`) # # Pros (vs binstubs or aliases): # * automatically adjusts to bundle changes @@ -14,8 +14,8 @@ # # Cons: # * Might be surprising at first ("I didn't type that!") # * Slows down `cd` and other directory change operations a bit (to recompute # the `RUN_WITH_BUNDLER` environment variable) # * Only works if the first token on the command line needs to be run with # bundler. (For example, if you try `env RAILS_ENV=test rake db:create`, # that won't work because `env` doesn't need to run under bundler. But in @@ -30,26 +30,32 @@ # # Configuration: # # 1. Drop this file in `~/.config/fish/bundler-exec.fish` # # 2. In `.config/fish/config.fish`, include these lines: # # if test -f ~/.config/fish/bundler-exec.fish # source ~/.config/fish/bundler-exec.fish # end # # 3. Add `~/.config/fish/functions/fish_user_key_bindings.fish` with # these lines: # # function fish_user_key_bindings # if functions -q _maybe-add-bundle-exec-and-execute # bind \r _maybe-add-bundle-exec-and-execute # end # end # # (or just add the inner if/end block to that function if you're # already defining it). # # 4. This *effectively* puts `.bundle/bin` at the start of `$PATH`, # so you may as well actually put it there so that completions # and suggestions will also work. (But you can't *just* do this # step, because the scripts in `.bundle/bin` are not binstubs, # so they won't load the bundle if executed directly.) # # Author: Glenn Vanderburg <[email protected]> begin -
glv revised this gist
Sep 20, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,7 +20,7 @@ # bundler. (For example, if you try `env RAILS_ENV=test rake db:create`, # that won't work because `env` doesn't need to run under bundler. But in # that very common case, I just use Rake's ability to take environment # overrides in *its* argument list instead: `rake RAILS_ENV=test db:create`.) # # Deficiencies: # * If you work simultaneously in projects that use bundler and others that -
glv revised this gist
Sep 20, 2017 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,6 +16,11 @@ # * Might be surprising at first ("I didn't type that!") # * Slows down cd and other directory change operations a bit (to recompute # the RUN_WITH_BUNDLER variable) # * Only works if the first token on the command line needs to be run with # bundler. (For example, if you try `env RAILS_ENV=test rake db:create`, # that won't work because `env` doesn't need to run under bundler. But in # that very common case, I just use Rake's ability to take environment # overrides in *its* argument list instead: `rake RAILS_ENV=test db:create`. # # Deficiencies: # * If you work simultaneously in projects that use bundler and others that @@ -95,6 +100,7 @@ begin set -l toks (commandline --tokenize) if contains $toks[1] $RUN_WITH_BUNDLER commandline "bundle exec $toks" commandline -f repaint end commandline -f execute end -
glv revised this gist
Sep 19, 2017 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,6 +17,12 @@ # * Slows down cd and other directory change operations a bit (to recompute # the RUN_WITH_BUNDLER variable) # # Deficiencies: # * If you work simultaneously in projects that use bundler and others that # use a similar tool, you might want to have things set up to work # appropriately with both tools. Currently this is not implemented so as # to compose well with similar packages. # # Configuration: # # 1. Drop this file in ~/.config/fish/bundler-exec.fish -
glv revised this gist
Sep 19, 2017 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,8 +8,9 @@ # # Pros (vs binstubs or aliases): # * automatically adjusts to bundle changes # * explicit (the command visible on your terminal and in your history is # "bundle exec whatever", and it's a nice reminder that bundler magic is # happening with those commands) # # Cons: # * Might be surprising at first ("I didn't type that!") -
glv revised this gist
Sep 19, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -63,7 +63,7 @@ begin if _bundler-installed and _within-bundled-project # This version is slow but simple and safe. # set -l bundler_path (bundle exec gem environment path) # This version is faster but complex and probably brittle. If -
glv revised this gist
Sep 19, 2017 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -37,6 +37,8 @@ # # (or just add the inner if/end block to that function if you're # already defining it). # # Author: Glenn Vanderburg <[email protected]> begin # Support Functions -
glv revised this gist
Sep 19, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -67,9 +67,9 @@ begin # This version is faster but complex and probably brittle. If # you're seeing flaky behavior around all of this, switch to the # slow version above and see if that fixes it. set -l bundle_path (bundle config path | sed -e '/^Set /!d;s/^.*: "\(.*\)".*$/\1/') set -gx RUN_WITH_BUNDLER (command ls "$bundle_path/bin") else set -ge RUN_WITH_BUNDLER end -
glv revised this gist
Sep 19, 2017 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -69,8 +69,7 @@ begin # slow version above and see if that fixes it. set -l bundler_path (bundle config path | sed -e '/^Set /!d;s/^.*: "\(.*\)".*$/\1/') set -gx RUN_WITH_BUNDLER (command ls "$bundler_path/bin") else set -ge RUN_WITH_BUNDLER end -
glv revised this gist
Sep 19, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ # prefix with "command" (e.g., "command rake -T") # # Pros (vs binstubs or aliases): # * automatically adjusts to bundle changes # * explicit (the command in your history is "bundle exec whatever", and it's # a nice reminder that bundler magic is happening with those commands) # -
glv created this gist
Sep 19, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,93 @@ # This sets up fish so that, if you type a command that should be # run using bundler, it first automatically prepends "bundle exec" # to the command line buffer before executing it. Works for all # commands found in the "bin" directory of the current bundle. # # To override this behavior and run such a command without bundler, # prefix with "command" (e.g., "command rake -T") # # Pros (vs binstubs or aliases): # * never needs updating (i.e., foolproof) # * explicit (the command in your history is "bundle exec whatever", and it's # a nice reminder that bundler magic is happening with those commands) # # Cons: # * Might be surprising at first ("I didn't type that!") # * Slows down cd and other directory change operations a bit (to recompute # the RUN_WITH_BUNDLER variable) # # Configuration: # # 1. Drop this file in ~/.config/fish/bundler-exec.fish # # 2. In .config/fish/config.fish, include these lines: # # if test -f ~/.config/fish/bundler-exec.fish # source ~/.config/fish/bundler-exec.fish # end # # 3. Add ~/.config/fish/functions/fish_user_key_bindings.fish with # these lines: # # function fish_user_key_bindings # if functions -q _maybe-add-bundle-exec-and-execute # bind \r _maybe-add-bundle-exec-and-execute # end # end # # (or just add the inner if/end block to that function if you're # already defining it). begin # Support Functions function _bundler-installed which bundle > /dev/null 2>&1 end function _within-bundled-project set -l dir (pwd) while test (dirname $dir) != "/" if test -f "$dir/Gemfile" -o -f "$dir/gems.rb" return end set -l dir (dirname $dir) end false end # Keep RUN_WITH_BUNDLER updated on directory changes function _discover_bundle --on-variable PWD if _bundler-installed and _within-bundled-project # This version is slow but simple and safe # set -l bundler_path (bundle exec gem environment path) # This version is faster but complex and probably brittle. If # you're seeing flaky behavior around all of this, switch to the # slow version above and see if that fixes it. set -l bundler_path (bundle config path | sed -e '/^Set /!d;s/^.*: "\(.*\)".*$/\1/') set -l bundler_bin "$bundler_path/bin" set -gx RUN_WITH_BUNDLER (command ls $bundler_bin) else set -ge RUN_WITH_BUNDLER end end # Before executing the current commandline buffer, prepend # "bundle exec" if the first token is one of the commands in # RUN_WITH_BUNDLER. # # (This depends on _discover_bundle running correctly on each # directory change, and on \r being re-bound to this function in # fish_user_key_bindings.) function _maybe-add-bundle-exec-and-execute set -l toks (commandline --tokenize) if contains $toks[1] $RUN_WITH_BUNDLER commandline "bundle exec $toks" end commandline -f execute end end