Skip to content
binaryfuntPublic

About

A cmd script to run posh-git

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-shell

A cmd script to run posh-git

Not to be confused with the git command git-shell

A demo of git-shell

In this demo, I'm using Hyper instead of PowerShell

Background

Git Shell logo

GitHub for Windows used to ship with a shortcut called Git Shell, which would launch PowerShell with the posh-git module. However, it no longer does, and there are no plans to do so in the future. I wrote this couple of scripts to create a command line shortcut to run posh-git, replicating the Git Shell experience (although without the physical start menu tile). It does however, allow for loading posh-git to an existing console.

Installation

Prerequisites

  • Git must be installed and available via the PATH environment variable

    • Check that git is accessible from PowerShell by executing git --version from PowerShell
    • If git is not recognized as the name of a command, verify that you have Git installed
    • If Git is not installed, download it from git-scm.com/download/
  • Posh-git must be installed

    • If you have previously installed the old version of GitHub for Windows, it will be in the %LOCALAPPDATA%\GitHub folder
      1. Open File Explorer and type %LOCALAPPDATA%\GitHub
      2. One of the folders will be called PoshGit_XXXXXXXXXXXXXXX with a log string of alphanumerics. Keep this folder open for now.
    • If not, go to the posh-git repo and follow the installation instructions

Instructions

  1. Get the scripts. Either:

    • Download the two scripts git-shell.cmd and git-shell-ps.ps1 to a folder called "git-shell" in your user directory (or a custom location)
    • Or cd to your user directory (or a custom location) and clone the repo there. You should then delete README.md, LICENCE and demo.gif.
  2. Right click git-shell-ps.ps1 and click Edit

    1. In the line Import-Module $env:LOCALAPPDATA\GitHub\PoshGit_XXXXXXXXXXXXXXXXXXXX\posh-git.psm1, change the filepath to your posh-git installation
    2. Set the default location to navigate to when git-shell is called without the parameter -here by changing the line cd ~\GitHub\ as appropriate. If you want to remain in the current directory when git-shell is called, delete the if-block.
  3. Add the git-shell folder to your PATH

    1. In Windows settings, search for "System environment" and click Edit the system environment variables
    2. Click the Environment Variables... button near the bottom
    3. Under either User variables or System variables, click on the Path variable and then click Edit...
    4. Click New and type in the location of your git-shell folder (e.g., %USERPROFILE%\git-shell)
    5. Click Ok etc.

Usage

> git-shell

Loads git-shell and navigates to your default folder (~\GitHub\ if you haven't changed it)

> git-shell -here

Loads git-shell in the current directory.

To change this behaviour, edit git-shell-ps.ps1. Do not edit git-shell.cmd unless you want to extend it (in which case why not create a fork of this repo).

> exit

Exits the session and returns to the last point before calling git-shell

Notes

If it keeps asking for a password to push changes to GitHub while using git, check out Git Credential Manager for Windows

About

A cmd script to run posh-git

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages