Commit graph

190 commits

Author SHA1 Message Date
Iván Sotillo del Horno 3cd63a1bbe
Feature: add interactive git switch selector (#472) 2025-12-10 20:19:26 +01:00
sandr01d 455e42ba64
Feature: add interactive reword selector (#443) 2025-05-29 20:51:12 +02:00
sandr01d c2b012855f
Feature: add interactive squash selector (#440) 2025-05-25 18:21:56 +02:00
sandr01d 38d74ba3ed
Fix: prefix all commands in forgit.plugin.zsh (#439)
* Fix: prefix all commands in forgit.plugin.zsh

This prevents the wrong commands getting executed in case a user added a
shell alias with the same name.

* Fix: prefix built-ins
2025-05-18 16:23:51 +02:00
sandroid 0d65efc769 Feature: Add interactive git attributes generator
Some checks failed
ci / build (macos-latest) (push) Waiting to run
ci / build (ubuntu-20.04) (push) Waiting to run
ci / build (ubuntu-22.04) (push) Failing after 1s
2025-02-14 20:29:33 +01:00
carlfriedrich bb83b3cba0
Feature: add forgit show command (#417)
Some checks failed
ci / build (ubuntu-22.04) (push) Failing after 1s
ci / build (macos-latest) (push) Has been cancelled
ci / build (ubuntu-20.04) (push) Has been cancelled
Introducing `show` as a new subcommand of `forgit`, an interactive
version of `git show`. The configured default alias is `gso`.

Alt-T can be used to toggle between showing the diff and the commit
message in the fzf preview window.

The new command in used instead of `forgit diff` when pressing enter
in `forgit log`. This fixes the display of diffs for merge commits.

**Note**: we have a requirement for the `fzf` version now. The minimum
required `fzf` version is 0.49.0. If the installed version is lower,
forgit will exit with an error message.

Fixes #416.
2025-01-29 07:04:07 +01:00
sandr01d be82c47ceb
Feature: Add interactive git reflog (#398)
Some checks failed
ci / build (ubuntu-22.04) (push) Failing after 1s
ci / build (macos-latest) (push) Has been cancelled
ci / build (ubuntu-20.04) (push) Has been cancelled
2024-09-04 22:02:27 +02:00
Wenxuan 714f6dfec1
fix: avoid polluting the global namespace (#347)
Signed-off-by: Wenxuan Zhang <wenxuangm@gmail.com>
2024-02-06 14:21:51 +08:00
Tom 99cda3248c
Restore support for appending FORGIT_INSTALL_DIR to path (#308)
It seems somewhere along the line FORGIT_INSTALL_DIR stopped getting exported. According to the README you can append it to your path to get access to git forgit ... commands however this seems to no longer work - this is an attempt to restore this functionality.
2023-05-16 08:45:52 -07:00
Tim aa85792ec4
Add bash completions for forgit functions and aliases (#275)
When using forgit via the shell plugin, source 'git-forgit.bash'
explicitly after 'forgit.plugin.zsh' to enable tab completion for forgit
shell functions and aliases.
2023-01-30 17:46:52 +01:00
sandr01d f8c0edfc17
Added git stash push selector 'gsp' (#251)
A message can be passed via named argument (-m or --message). All other
arguments (e.g. file paths) will cause git stash push to be run directly without
invoking fzf.
2022-12-14 15:53:52 +01:00
Markus Meier bfea8cf485
fix: compatibility check not working in bash (#258)
Fix: backwards compatibility check not working reliably in bash
2022-12-09 09:54:58 +01:00
carlfriedrich 372239fd37 Export user-defined FORGIT variables for backwards compatibility
Before forgit became a standalone script, users defined their FORGIT
variables (e.g. FORGIT_FZF_DEFAULT_OPTS) in the shell environment before
sourcing the forgit shell plugin. This worked because the forgit code
was executed within the currently running shell.
With forgit being an executable script, these variables are only
available to forgit when being exported. This patch adds an automatism
for this so that users do not have to change their configuration.
A warning is issued in this case so that users get notified to update
their configuration.
2022-11-17 10:19:32 +01:00
carlfriedrich 0820811862 Add variable for forgit binary 2022-11-14 17:53:00 +01:00
carlfriedrich b2d24138df zsh plugin: exit with an error if bin path cannot be determined 2022-11-14 17:53:00 +01:00
carlfriedrich 9471f292bb zsh plugin: use standardized $0 handling
See https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html#zero-handling
2022-11-14 17:53:00 +01:00
carlfriedrich 4995c614e4 Move implementation to standalone forgit
Previously we had two different forgit implementations: one for zsh/bash
and one for fish. In this commit we move the bash implementation of the
forgit functions to the git-forgit script in order to have them in the
form of an executable script. This makes using forgit possible without
any shell plugin at all and furthermore removes the need to maintain a
separate implementation for the fish shell.

The simplest way of using forgit from now on is to put git-forgit
somewhere in your PATH and call it via "git forgit", without the need
for any other files.

We keep the shell plugins, though, and maintain backwards compatibility
by retaining the plugin functions as simple wrappers around the
git-forgit script, making the plugins mainly a collection of aliases
only.
2022-11-14 17:52:58 +01:00
Tim 49579b2d1f
Do not return an error in log, diff and stash show (#236)
fzf has the following exit codes:
0      Normal exit
1      No match
2      Error
130    Interrupted with CTRL-C or ESC

The forgit functions "log", "diff" and "stash show" are designed to
display information, not to perform any action. Hence the fzf exit code
130 should not be interpreted as an error, it is normal exit behavior.
Exclude this error value and return 0 in this case.
2022-09-17 18:16:30 +02:00
Tim e0ca1f4045
Add ability to checkout existing branch with gcb (#234)
Port @cjappl 's changes of #232 / d4b4ce3 to zsh/bash.

gcb can now be called with an existing branch as an argument.
2022-09-13 07:38:32 -07:00
Wenxuan 2a96f287a9
Merge pull request #228 from carlfriedrich/interactively-select-branch-in-gcp
Interactively select branch in gcp
2022-09-13 10:32:18 +08:00
Wenxuan 85bc57a15c
Merge pull request #226 from carlfriedrich/support-stashes-in-gd
Support stashes in forgit::diff
2022-08-15 10:13:34 +08:00
Wenxuan e78562250f
Merge pull request #225 from carlfriedrich/add-forgit-enter-pager
Add variable FORGIT_ENTER_PAGER
2022-08-15 10:06:43 +08:00
ccoVeille f6040b21a0
fix typo in comments and README files (#230) 2022-08-09 19:07:59 -07:00
carlfriedrich b9c0e7b58f gcp: interactively select target branch
When we want to perform a cherry pick, we had to pass the target branch
as an argument to gcp. Forgit, however, aims to make git selections
interactive where possible. Hence it seems natural to select the target
branch interactively as well.
2022-08-06 19:30:49 +02:00
carlfriedrich 1e080b0e72 Introduce variable "forgit_log_preview_options"
This reduces code duplication.
2022-08-03 18:08:55 +02:00
carlfriedrich c167918098 Support stashes in forgit::diff
Git stashes are named "stash@{x}", which contains the fzf placeholder
"{x}". In order to support passing stashes as arguments to forgit::diff,
we have to prevent fzf from interpreting this substring by escaping the
opening bracket.
2022-08-03 09:24:25 +02:00
carlfriedrich 25e1a2e277 Add variable FORGIT_ENTER_PAGER
The pager used on fzf enter key binding commands was hardcoded to
"LESS='-r' less". Transfer this to a variable in order to reduce code
duplication and make it configurable.
2022-08-01 13:39:47 +02:00
zhangwenxuan.917 85ccdd3f80 fix: make linter happy 2022-07-28 16:29:49 +08:00
carlfriedrich 126772f08c Add function forgit::previous_commit 2022-07-28 10:16:22 +02:00
carlfriedrich d343300625 grb: rebase on parent of the selected commit
The git rebase command needs to be passed the parent commit of the one
you want to edit. When selecting a commit interactively via fzf, it
makes sense to automatically pass the parent commit of the selected one.
Within fzf it's otherwise quite hard to find the parent commit by hand
if you have found your commit via an fzf search string.
2022-07-28 10:14:37 +02:00
carlfriedrich 7b1ebff09f Add variable "forgit_extract_sha"
This reduces code duplication. We cannot implement this as a function,
because fish and zsh do not support exporting functions, but we need it
in subshells (see https://github.com/fish-shell/fish-shell/issues/6961).
Implement it as a variable in all shells instead.
2022-07-26 09:21:42 +02:00
carlfriedrich 8d3ecb6ccf Add variables for diff context
Introduce FORGIT_DIFF_CONTEXT for the diff context when viewing a diff
and FORGIT_PREVIEW_CONTEXT for the diff context in the preview window.
2022-07-22 14:26:08 +02:00
carlfriedrich bb4514a359 Improve forgit::diff
* Show additional context on enter compared to preview
* Show selected diff range in fzf prompt
2022-07-17 16:42:11 +02:00
Tim fdd5632b17
Fix cherry pick preview (#218)
The preview on cherry pick was accidentally broken since we included the
+/- information in the commit list. Fix this by using the correct string
index.
2022-07-14 09:24:56 -07:00
carlfriedrich fe5c4d9881 Reverse order on cherry pick
Git log displays the newest commits on top of the list, while git cherry
pick displays the newest commits at the bottom. Reverse the order of
git cherry pick so that it has the same order like git log.
2022-07-13 12:33:55 +02:00
carlfriedrich 1b7db0fb6e Preserve +/- information on cherry pick
The output of 'git cherry' which is used to build the fzf input list for
forgit::cherry::pick usually prefixes every line with a '-' for commits
that have an equivalent in the target branch, and a '+' for commits that
do not.

Previously forgit removed this information from the list. However, for
the actual cherry-picking process this information is relevant, so we
should keep it.
2022-07-12 16:42:18 +02:00
carlfriedrich 52d79009d1 Preserve commit order on cherry pick
When using a fzf find string which maches multiple lines, the commits
could appear in a wrong order. Add "--tiebreak=index" to ensure that the
correct commit order is preserved.
2022-07-12 16:35:54 +02:00
carlfriedrich 53d0ea2f38 Add FORGIT_CHERRY_PICK_FZF_OPTS
The gcp (git cherry pick) command was the only command which did not
have a variable to set command-specific fzf options. Add the according
variable to source code and documentation.
2022-07-12 16:35:54 +02:00
sandroid f8b1fc8545
Changed alias for forgit::blame to gbl 2022-06-16 22:34:13 +02:00
sandroid 2d3dd568bb
gb: handle untracked files 2022-06-03 23:24:40 +02:00
sandroid 958e26add5
Added gb 2022-06-02 23:22:41 +02:00
Wenxuan 6385f85360
fix: gd show empty preview when path has spaces in zsh/bash (#204) 2022-05-28 17:04:23 -07:00
Wenxuan Zhang 544cf86bc4
docs: update comment 2022-05-20 17:44:51 +08:00
Chris Apple 75e9d12bac
Adding support for git branch delete method (#200)
* Adding support for git branch delete method in fish

* Add new doc to README

* Added options like gcb

* refactor: remove `--all` flag from gbd

* feat: sync forgit::branch::delete to bash and zsh

Co-authored-by: Wenxuan Zhang <wenxuangm@gmail.com>
2022-05-11 09:41:21 -07:00
Wenxuan 0c4a3069ba
Merge pull request #199 from max-ae/fix/gd-spaces
fix: `forgit::diff` not working if repo path contains spaces
2022-05-10 10:02:04 +08:00
Max Eisner 25bb8aee24 fix: forgit::diff not working if repo path contains spaces 2022-05-10 10:00:57 +08:00
Pablo M. Bermudo Garay 4dd2ca2271 Fix gcb sort
Use LC_ALL=C to avoid potential ordering issues related to the user's
locale configuration. Additionally, add the --stable option to ensure
that just the range defined with --key is used.
2022-04-06 15:48:49 +02:00
Pablo M. Bermudo Garay d32e3c282b Fix gcb verbose output
Delete the verbose option of git checkout, so just the branch names are
displayed.
2022-04-06 15:47:06 +02:00
sandroid 6a9c0e3f82
Refactored grc 2022-04-01 23:41:00 +02:00
sandroid e4874bf763
Replaced eval in grc 2022-04-01 22:01:37 +02:00