Skip to content

👷 [oh-my-zsh plugin] git clone and change directory by a single command

License

Notifications You must be signed in to change notification settings

viko16/gitcd.plugin.zsh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gitcd.plugin.zsh

👷 [oh-my-zsh plugin] git clone and change directory by a single command

Installation

  1. Clone this repository into $ZSH_CUSTOM/plugins (by default ~/.oh-my-zsh/custom/plugins)

    git clone https://github.com/viko16/gitcd.plugin.zsh ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/gitcd
  2. Add the plugin to the list of plugins for Oh My Zsh to load (inside ~/.zshrc):

    plugins=(gitcd)
  3. Start a new terminal session.

Usage

$ gitcd <repo-url>

Example:

$ gitcd https://github.com/viko16/gitcd.plugin.zsh.git
# => will git clone and cd to "~/Code/github.com/viko16/gitcd.plugin.zsh"

If the repository is already cloned to local, it will automatically "cd" there.

Config

By default, gitcd will git clone under ~/Code/<host>/<path>. If you want to change base dir, just set Environmental Variable name GITCD_HOME.

Example:

$ export GITCD_HOME=~/myworkspace
$ gitcd https://github.com/facebook/react
# => ~/myworkspace/github.com/facebook/react

To omit the part from the local clone path, set GITCD_USEHOST to false (the value is not case sensitive).

Example:

$ export GITCD_HOME=~/myworkspace GITCD_USEHOST=false
$ gitcd https://github.com/facebook/react
# => ~/myworkspace/facebook/react

Test

zsh ./test.zsh

Thanks

License

MIT License © viko16

About

👷 [oh-my-zsh plugin] git clone and change directory by a single command

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages