How do I get bash completion to work with aliases in Windows 10 bash?












3














I have an aliases.sh file modified with



alias gc='git checkout'


and upon checking out a long branch name, if I type
gc <branchstring> + TAB , auto-complete doesn't work, in order for the full branch name to appear.










share|improve this question



























    3














    I have an aliases.sh file modified with



    alias gc='git checkout'


    and upon checking out a long branch name, if I type
    gc <branchstring> + TAB , auto-complete doesn't work, in order for the full branch name to appear.










    share|improve this question

























      3












      3








      3


      2





      I have an aliases.sh file modified with



      alias gc='git checkout'


      and upon checking out a long branch name, if I type
      gc <branchstring> + TAB , auto-complete doesn't work, in order for the full branch name to appear.










      share|improve this question













      I have an aliases.sh file modified with



      alias gc='git checkout'


      and upon checking out a long branch name, if I type
      gc <branchstring> + TAB , auto-complete doesn't work, in order for the full branch name to appear.







      git






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 18 '18 at 23:42









      RiddickRiddick

      82110




      82110
























          1 Answer
          1






          active

          oldest

          votes


















          1














          I looked through everything in this thread to try to make it work for & tailor what kpsfoo said, but for the Windows 10 OS.



          The steps would be to:



          1) Copy the git-completion.bash file from



          <your git install folder>/etc/git-completion.bash


          to



          C:Users<YourUserName>git-completion.bash



          2) add this line of code:



          source ~/git-completion.bash to your aliases.sh file



          (which can be found in <your git install folder>etcprofile.d )



          3) Add alias gc='git checkout'
          &
          Add __git_complete gco _git_checkout anywhere after the source ~/git-completion.bash line in your aliases.sh file.



          4) Reboot your git bash and enjoy your alias auto completion!



          Example:
          If I have a branch VeryVeryLongBranchName and I'm currently on dev branch, and want to switch to it, instead of typing
          git checkout VeryVeryLongBranchName I can type only
          gc Very +TAB key and it is the equivalent of the instruction above.



          An example of everything that I have in my aliases.sh file (and it will be expanded, as I find the need for other aliases) would be:



          alias ga="git add"
          alias gb='git branch'
          alias gba="git branch -a"
          alias gc='git checkout'
          alias gcb='git checkout -b'
          alias gcam='git commit -a -m'
          alias gm='git merge --no-ff'
          alias gps='git push wpdev dev'
          alias gpsm='git push wpdev master'
          alias gpl='git pull wpdev dev'
          alias gplm='git pull wpdev master'
          alias st='git status'
          alias l='git log --graph --pretty='''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset''' --abbrev-commit'
          alias last='log -1 HEAD'
          alias gs='git stash'

          # Enable the __git_complete function to autocomplete aliases once you press TAB
          source ~/git-completion.bash

          __git_complete ga _git_add
          __git_complete gc _git_checkout
          __git_complete gm _git_merge
          __git_complete gb _git_branch
          __git_complete gba _git_branch
          __git_complete l _git_log

          case "$TERM" in
          xterm*)
          # The following programs are known to require a Win32 Console
          # for interactive usage, therefore let's launch them through winpty
          # when run inside `mintty`.
          for name in node ipython php php5 psql python2.7
          do
          case "$(type -p "$name".exe 2>/dev/null)" in
          ''|/usr/bin/*) continue;;
          esac
          alias $name="winpty $name.exe"
          done
          ;;
          esac


          -worth of note: alias gm='git merge --no-ff' goes just fine with __git_complete gm _git_merge (when typing gm plus a string from your branch name and pressing TAB, it will autocomplete, and, after you run the command, the merge will take into consideration the --no-ff rule)






          share|improve this answer























          • Good answer, note that zsh works without any manual tweaking.
            – ideasman42
            2 days ago











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53366574%2fhow-do-i-get-bash-completion-to-work-with-aliases-in-windows-10-bash%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          I looked through everything in this thread to try to make it work for & tailor what kpsfoo said, but for the Windows 10 OS.



          The steps would be to:



          1) Copy the git-completion.bash file from



          <your git install folder>/etc/git-completion.bash


          to



          C:Users<YourUserName>git-completion.bash



          2) add this line of code:



          source ~/git-completion.bash to your aliases.sh file



          (which can be found in <your git install folder>etcprofile.d )



          3) Add alias gc='git checkout'
          &
          Add __git_complete gco _git_checkout anywhere after the source ~/git-completion.bash line in your aliases.sh file.



          4) Reboot your git bash and enjoy your alias auto completion!



          Example:
          If I have a branch VeryVeryLongBranchName and I'm currently on dev branch, and want to switch to it, instead of typing
          git checkout VeryVeryLongBranchName I can type only
          gc Very +TAB key and it is the equivalent of the instruction above.



          An example of everything that I have in my aliases.sh file (and it will be expanded, as I find the need for other aliases) would be:



          alias ga="git add"
          alias gb='git branch'
          alias gba="git branch -a"
          alias gc='git checkout'
          alias gcb='git checkout -b'
          alias gcam='git commit -a -m'
          alias gm='git merge --no-ff'
          alias gps='git push wpdev dev'
          alias gpsm='git push wpdev master'
          alias gpl='git pull wpdev dev'
          alias gplm='git pull wpdev master'
          alias st='git status'
          alias l='git log --graph --pretty='''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset''' --abbrev-commit'
          alias last='log -1 HEAD'
          alias gs='git stash'

          # Enable the __git_complete function to autocomplete aliases once you press TAB
          source ~/git-completion.bash

          __git_complete ga _git_add
          __git_complete gc _git_checkout
          __git_complete gm _git_merge
          __git_complete gb _git_branch
          __git_complete gba _git_branch
          __git_complete l _git_log

          case "$TERM" in
          xterm*)
          # The following programs are known to require a Win32 Console
          # for interactive usage, therefore let's launch them through winpty
          # when run inside `mintty`.
          for name in node ipython php php5 psql python2.7
          do
          case "$(type -p "$name".exe 2>/dev/null)" in
          ''|/usr/bin/*) continue;;
          esac
          alias $name="winpty $name.exe"
          done
          ;;
          esac


          -worth of note: alias gm='git merge --no-ff' goes just fine with __git_complete gm _git_merge (when typing gm plus a string from your branch name and pressing TAB, it will autocomplete, and, after you run the command, the merge will take into consideration the --no-ff rule)






          share|improve this answer























          • Good answer, note that zsh works without any manual tweaking.
            – ideasman42
            2 days ago
















          1














          I looked through everything in this thread to try to make it work for & tailor what kpsfoo said, but for the Windows 10 OS.



          The steps would be to:



          1) Copy the git-completion.bash file from



          <your git install folder>/etc/git-completion.bash


          to



          C:Users<YourUserName>git-completion.bash



          2) add this line of code:



          source ~/git-completion.bash to your aliases.sh file



          (which can be found in <your git install folder>etcprofile.d )



          3) Add alias gc='git checkout'
          &
          Add __git_complete gco _git_checkout anywhere after the source ~/git-completion.bash line in your aliases.sh file.



          4) Reboot your git bash and enjoy your alias auto completion!



          Example:
          If I have a branch VeryVeryLongBranchName and I'm currently on dev branch, and want to switch to it, instead of typing
          git checkout VeryVeryLongBranchName I can type only
          gc Very +TAB key and it is the equivalent of the instruction above.



          An example of everything that I have in my aliases.sh file (and it will be expanded, as I find the need for other aliases) would be:



          alias ga="git add"
          alias gb='git branch'
          alias gba="git branch -a"
          alias gc='git checkout'
          alias gcb='git checkout -b'
          alias gcam='git commit -a -m'
          alias gm='git merge --no-ff'
          alias gps='git push wpdev dev'
          alias gpsm='git push wpdev master'
          alias gpl='git pull wpdev dev'
          alias gplm='git pull wpdev master'
          alias st='git status'
          alias l='git log --graph --pretty='''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset''' --abbrev-commit'
          alias last='log -1 HEAD'
          alias gs='git stash'

          # Enable the __git_complete function to autocomplete aliases once you press TAB
          source ~/git-completion.bash

          __git_complete ga _git_add
          __git_complete gc _git_checkout
          __git_complete gm _git_merge
          __git_complete gb _git_branch
          __git_complete gba _git_branch
          __git_complete l _git_log

          case "$TERM" in
          xterm*)
          # The following programs are known to require a Win32 Console
          # for interactive usage, therefore let's launch them through winpty
          # when run inside `mintty`.
          for name in node ipython php php5 psql python2.7
          do
          case "$(type -p "$name".exe 2>/dev/null)" in
          ''|/usr/bin/*) continue;;
          esac
          alias $name="winpty $name.exe"
          done
          ;;
          esac


          -worth of note: alias gm='git merge --no-ff' goes just fine with __git_complete gm _git_merge (when typing gm plus a string from your branch name and pressing TAB, it will autocomplete, and, after you run the command, the merge will take into consideration the --no-ff rule)






          share|improve this answer























          • Good answer, note that zsh works without any manual tweaking.
            – ideasman42
            2 days ago














          1












          1








          1






          I looked through everything in this thread to try to make it work for & tailor what kpsfoo said, but for the Windows 10 OS.



          The steps would be to:



          1) Copy the git-completion.bash file from



          <your git install folder>/etc/git-completion.bash


          to



          C:Users<YourUserName>git-completion.bash



          2) add this line of code:



          source ~/git-completion.bash to your aliases.sh file



          (which can be found in <your git install folder>etcprofile.d )



          3) Add alias gc='git checkout'
          &
          Add __git_complete gco _git_checkout anywhere after the source ~/git-completion.bash line in your aliases.sh file.



          4) Reboot your git bash and enjoy your alias auto completion!



          Example:
          If I have a branch VeryVeryLongBranchName and I'm currently on dev branch, and want to switch to it, instead of typing
          git checkout VeryVeryLongBranchName I can type only
          gc Very +TAB key and it is the equivalent of the instruction above.



          An example of everything that I have in my aliases.sh file (and it will be expanded, as I find the need for other aliases) would be:



          alias ga="git add"
          alias gb='git branch'
          alias gba="git branch -a"
          alias gc='git checkout'
          alias gcb='git checkout -b'
          alias gcam='git commit -a -m'
          alias gm='git merge --no-ff'
          alias gps='git push wpdev dev'
          alias gpsm='git push wpdev master'
          alias gpl='git pull wpdev dev'
          alias gplm='git pull wpdev master'
          alias st='git status'
          alias l='git log --graph --pretty='''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset''' --abbrev-commit'
          alias last='log -1 HEAD'
          alias gs='git stash'

          # Enable the __git_complete function to autocomplete aliases once you press TAB
          source ~/git-completion.bash

          __git_complete ga _git_add
          __git_complete gc _git_checkout
          __git_complete gm _git_merge
          __git_complete gb _git_branch
          __git_complete gba _git_branch
          __git_complete l _git_log

          case "$TERM" in
          xterm*)
          # The following programs are known to require a Win32 Console
          # for interactive usage, therefore let's launch them through winpty
          # when run inside `mintty`.
          for name in node ipython php php5 psql python2.7
          do
          case "$(type -p "$name".exe 2>/dev/null)" in
          ''|/usr/bin/*) continue;;
          esac
          alias $name="winpty $name.exe"
          done
          ;;
          esac


          -worth of note: alias gm='git merge --no-ff' goes just fine with __git_complete gm _git_merge (when typing gm plus a string from your branch name and pressing TAB, it will autocomplete, and, after you run the command, the merge will take into consideration the --no-ff rule)






          share|improve this answer














          I looked through everything in this thread to try to make it work for & tailor what kpsfoo said, but for the Windows 10 OS.



          The steps would be to:



          1) Copy the git-completion.bash file from



          <your git install folder>/etc/git-completion.bash


          to



          C:Users<YourUserName>git-completion.bash



          2) add this line of code:



          source ~/git-completion.bash to your aliases.sh file



          (which can be found in <your git install folder>etcprofile.d )



          3) Add alias gc='git checkout'
          &
          Add __git_complete gco _git_checkout anywhere after the source ~/git-completion.bash line in your aliases.sh file.



          4) Reboot your git bash and enjoy your alias auto completion!



          Example:
          If I have a branch VeryVeryLongBranchName and I'm currently on dev branch, and want to switch to it, instead of typing
          git checkout VeryVeryLongBranchName I can type only
          gc Very +TAB key and it is the equivalent of the instruction above.



          An example of everything that I have in my aliases.sh file (and it will be expanded, as I find the need for other aliases) would be:



          alias ga="git add"
          alias gb='git branch'
          alias gba="git branch -a"
          alias gc='git checkout'
          alias gcb='git checkout -b'
          alias gcam='git commit -a -m'
          alias gm='git merge --no-ff'
          alias gps='git push wpdev dev'
          alias gpsm='git push wpdev master'
          alias gpl='git pull wpdev dev'
          alias gplm='git pull wpdev master'
          alias st='git status'
          alias l='git log --graph --pretty='''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset''' --abbrev-commit'
          alias last='log -1 HEAD'
          alias gs='git stash'

          # Enable the __git_complete function to autocomplete aliases once you press TAB
          source ~/git-completion.bash

          __git_complete ga _git_add
          __git_complete gc _git_checkout
          __git_complete gm _git_merge
          __git_complete gb _git_branch
          __git_complete gba _git_branch
          __git_complete l _git_log

          case "$TERM" in
          xterm*)
          # The following programs are known to require a Win32 Console
          # for interactive usage, therefore let's launch them through winpty
          # when run inside `mintty`.
          for name in node ipython php php5 psql python2.7
          do
          case "$(type -p "$name".exe 2>/dev/null)" in
          ''|/usr/bin/*) continue;;
          esac
          alias $name="winpty $name.exe"
          done
          ;;
          esac


          -worth of note: alias gm='git merge --no-ff' goes just fine with __git_complete gm _git_merge (when typing gm plus a string from your branch name and pressing TAB, it will autocomplete, and, after you run the command, the merge will take into consideration the --no-ff rule)







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 23 '18 at 15:55

























          answered Nov 18 '18 at 23:42









          RiddickRiddick

          82110




          82110












          • Good answer, note that zsh works without any manual tweaking.
            – ideasman42
            2 days ago


















          • Good answer, note that zsh works without any manual tweaking.
            – ideasman42
            2 days ago
















          Good answer, note that zsh works without any manual tweaking.
          – ideasman42
          2 days ago




          Good answer, note that zsh works without any manual tweaking.
          – ideasman42
          2 days ago


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53366574%2fhow-do-i-get-bash-completion-to-work-with-aliases-in-windows-10-bash%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

          ComboBox Display Member on multiple fields

          Is it possible to collect Nectar points via Trainline?