Oh-my-fish: Add git shortcuts

Created on 9 Jun 2016  路  6Comments  路  Source: oh-my-fish/oh-my-fish

I recently moved from zsh to fish and the thing I miss the most are the git shortcuts...
Such as
gst for git status
gup for git pull --rebase
gp for git push
etc...

I couldn't find any plugin that did this... Can it be enabled by default?

plugins

Most helpful comment

Generally, plugins that only setup aliases are frowned upon as they are too personal. As far as I'm aware there are no plugins of that type in the database. Yet, you can create your own aliases in init.fish with the alias builtin. Like so, alias gst="git status".

All 6 comments

Generally, plugins that only setup aliases are frowned upon as they are too personal. As far as I'm aware there are no plugins of that type in the database. Yet, you can create your own aliases in init.fish with the alias builtin. Like so, alias gst="git status".

I have the following in git_alias.fish which I source from init.fish:

alias gd="git diff"
alias gdc="git diff --cached"
alias ga="git add"
alias gca="git commit -a -m"
alias gcm="git commit -m"
alias gbd="git branch -D"
alias gst="git status -sb --ignore-submodules"
alias gm="git merge --no-ff"
alias gpt="git push --tags"
alias gp="git push"
alias grs="git reset --soft"
alias grh="git reset --hard"
alias gb="git branch"
alias gcob="git checkout -b"
alias gco="git checkout"
alias gba="git branch -a"
alias gcp="git cherry-pick"
alias gl="git lg"
alias gpom="git pull origin master"

Even in zsh I am pretty certain that the git aliases are not enabled by default, and @lfiolhais is right. Aliases are personal and so if we accept one git aliases plugin, it will be joined immediately with 10 other slightly or completely different variants.

Hence, you are left with two options:

  1. As stated above, you can have your aliases set in init.fish (or some file sourced from it).
  2. If you insist, create a plugin and share it with friends and colleagues. The plugin will not enter the official registry, but it's still possible to install and manage (update/remove) a plugin with the full url of the repository.
    e.g.: omf install https://github.com/aayushkapoor206/omf-plugin-gitaliases.git
    and omf remove gitaliases

Hi @aayushkapoor206, you can have a look at my own minimal aliases:

https://github.com/derekstavis/plugin-minimal-git-aliases

Give a look at the names I'm using:

https://github.com/derekstavis/plugin-minimal-git-aliases/blob/master/init.fish

where is the init.fish you guys are referring too, can someone please provide me the path for the file?

@KhaledMohamedP see where your OMF_CONFIG is by running echo $OMF_CONFIG. If init.fish doesn't exist in that path, you can create it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

quenode picture quenode  路  6Comments

pydo picture pydo  路  6Comments

edoarda picture edoarda  路  7Comments

calebmeyer picture calebmeyer  路  4Comments

NineSwordsMonster picture NineSwordsMonster  路  4Comments