Commit Graph

83 Commits

Author SHA1 Message Date
740c0b2fd7 git: Add git-abort & git-continue
I find typing `git {rebase,merge,...} --{continue,abort}` a bit
annoying, since it is a lot of typing. I have added an alias for `rebase
--continue` (grc), but the problem remained for the other commands.

Add a script that continues or aborts the ongoing process by detecting
it automatically.
2025-06-19 14:03:17 +02:00
0c17ae8280 *: Use xargs instead of while read one-line loops 2025-05-27 17:00:35 +02:00
9836b51e16 zsh:glog: Use execute-silent when copying the hash
This way the screen does not flash.
2025-05-23 18:19:03 +02:00
e3689fe68b zsh:glog: Fix some non-local variables 2025-05-23 18:18:35 +02:00
00d28845a3 zsh:glog: Fix preview with files that were renamed
Previously when calling `glog -- file` with a file that was renamed
sometime in the history, the preview would just be empty for all commits
before the rename, since it's path didn't exist.

Fix this by checking for empty output and falling back to the full patch
in that case.

This also heavily refactors the code around `$fzf_preview` to make it
more readable.

TODO: It would be nice if git-show would fail in this case instead of
      just printing nothing and returning zero
2025-05-23 18:09:02 +02:00
339ef90db0 zsh:glog: Rename $out to $hash 2025-05-23 16:44:24 +02:00
e232c8f37b zsh:glog: Use single quotes for file arguments
Since they get interpreted by a shell again, weird file names (e.g.
including dollar signs) would not be passed literally in double quotes.
2025-05-23 16:01:19 +02:00
c8c9d887f5 git:checkout-worktree: Echo non-zero exit code 2025-01-29 14:27:11 +01:00
0c0231a2ef git:ssync: Add --new flag
I sometimes do not want to change the working tree of submodules I
changed locally.
2025-01-28 17:25:46 +01:00
1783ee681a glog: More sticky header improvements 2025-01-22 14:56:08 +01:00
e4cab6d581 git:https-and-ssh: Print new remotes when done 2025-01-21 18:22:19 +01:00
c6cdc6ec78 git:https-and-ssh: Swap the if blocks
My brain assumes that the first block handles the case of the url being
an https one if I read http in the condition. Swap them and negate the
condition for better readability.

This might be a symptom of this condition being to complex, but well -
it's shell scripting ¯\_(ツ)_/¯
2025-01-21 18:08:18 +01:00
149643a31f git:https-and-ssh: Fix ssh -> https
Apparently there was an issue with the conversion from ssh to https
which I never noticed? The script would replace the colon of the
`https://` and not the one after the domain:

    https///github.com:[...]

I rewrote both cases in a simpler way while fixing the issue.
2025-01-21 18:01:51 +01:00
aa4af50cde glog: s/full/patch in header to understand the bindings 2025-01-08 11:21:07 +01:00
d82ad9e8b9 glog: Color the key mappings overview
TODO: Use variables for colors and make customizable
2024-11-01 02:56:15 +01:00
7709ece0f8 glog: Add --highlight-line 2024-11-01 02:42:24 +01:00
9c099416a9 glog: Explicitly set my general fzf bindings
`glog` is the most standalone tool out of my dotfiles and I know of at
least one person that uses it that way. Because of this I want to also
explicitly map all other bindings that I have in my zprofile to improve
the experience.
2024-11-01 02:36:15 +01:00
9802309f12 glog: Display key bindings in sticky header 2024-11-01 02:23:34 +01:00
8be1c63c18 glog: Fix coloring when scrolling
Due to the formatting placeholders sitting on the previous line, the
coloring of the topmost line disappeared when scrolling (as the escape
sequence scrolled away). This had the background that I wanted the code
that sets up the format string to be very readable and if possible very
close to the actual output. And since the colors have all different
lengths I decided to place them on the previous line to have them out of
the way.

Fix this by placing the placeholders on the same output line while still
maintaining a readable format string (code). This is done by joining the
array without placing newlines so that it can now have multiple elements
for one output line and formatting those as wished.
2024-11-01 01:55:03 +01:00
ed4dac6f82 glog: Make changing previews persistent
Switch to using the `change-preview()` action that was introduced in
0.29.0 (which was actually not yet released for a year when this feature
was first written). The old `preview()` is a one-off action while
`change-preview()` changes the `--preview` option.

This had the downside that when changing to a different preview and
moving to the next commit one would had to repeat the change. This was
especially annoying when looking through the history of a file that was
renamed. With the commit that renamed the file all previous commits
broke in the `files_only` preview as the path didn't exist yet (A
possible but probably pretty hard TODO to fix).

TODO: glog: Fix files_only preview for renamed files or give prompt to
      change the paths
2024-11-01 01:30:43 +01:00
c7aae00e65 glog: Use core.pager also for Enter action 2024-10-30 15:53:28 +01:00
19fc37299a git:https-and-ssh: Make POSIX-shell compliant
Don't know why this had two shebangs and how I never noticed.
Apparently I only launched the script through the autoloaded
function in zsh.
2024-10-30 10:52:01 +01:00
4d32370ba2 glog: Use git's core.pager
This way diff-so-fancy can easily be replaced/customized.
2024-10-30 10:52:00 +01:00
31fcce9491 glog: Put angle brackets around email addresses
This makes it easier to copy the line and directly use it in git
trailers (e.g. Reviewed-by).
2024-04-25 11:40:26 +02:00
ffc9877a70 git:last-changed: Print committer name too
I am still unsure if I want the author or committer name. For the date I
think it makes sense to have the committer date since it reflects better
when the branch last changed.
2024-03-24 13:50:12 +01:00
234f452434 git:make-fork: Add call to git-https-and-ssh
When setting up the remotes the fetch url can use https since the fork
will be public anyways. This delays a prompt for the ssh key until it is
really necessary.
2024-03-24 13:46:42 +01:00
58243e0510 *: Update and add TODOs 2024-01-05 16:20:42 +01:00
5747b6e04c git:commit-last-msg: Make more robust
Use core.commentchar to identify commented lines and use the cut line
instead of just deleting from the first comment on, as this would break
for example in git generated messages (e.g. squashes).
2024-01-05 16:10:55 +01:00
50eecf7e01 git:perm-stash: Use stash's ancestor as commit_ref
The stash does not necessarily apply to HEAD.
2023-07-18 14:33:55 +02:00
d38ee159ed git: Add perm-stash to save a stash to a file 2023-07-18 14:30:09 +02:00
739e03b5a7 git:glog: Remove by-now default fzf bindings
These were added "globally" to FZF_DEFAULT_OPTS in 4f5d23bd1 ("zprofile:
Add some bindings to FZF_DEFAULT_OPTS").
2023-06-24 11:05:32 +02:00
5deb69bbd6 git:checkout-worktree: Improve name on recursion
When calling git-checkout-worktree from inside a temporary working tree
(doesn't necessary need to be a recursive call, could be another shell
too) the name would be very long.

Fix this by using the folder name of the main working tree.
2023-04-11 23:24:52 +02:00
44e83ee8d6 git:glog:TODO: Better file arguments handling 2023-02-27 14:01:49 +01:00
10824feb74 git:checkout-worktree: Make errc variable local 2023-02-13 17:18:25 +01:00
28f60004de git:checkout-worktree: Fix unset ret variable 2023-02-13 17:17:49 +01:00
0625fdbd94 git:last-changed: Fix handling of weird filenames
Make sure that `git-log` does not misunderstand the file name.
2023-02-13 17:13:41 +01:00
0a749cd6f5 git:last-changed: Equalize ANSI sanitization regex
Don't know why I used two different patterns.
2023-02-13 17:08:16 +01:00
78a7b0d809 git:glog:TODO: Depend preview function on --stat 2023-02-09 13:22:19 +01:00
8baaaf0e94 git:glog:TODO: Display ... in patch-stat 2023-02-09 13:21:00 +01:00
9449b7fecd git:glog: Respect file arguments when previewing
When file arguments were passes behind `--`, show only these files in
the patch preview. This mimics the behaviour of `git log -up --
<files>`.

The full patch can still be displayed with ctrl-p.
2023-02-09 13:17:32 +01:00
47e13d36a6 git:https-and-ssh: Support passing custom remote 2023-01-25 03:06:57 +01:00
c8b634b81f git:https-and-ssh: Use shorter variant to get url 2023-01-21 01:57:37 +01:00
0ae5f17dd0 git:last-changed: Fix truncation of colored lines
`cut` counts bytes instead of printable character, making it truncate
colored lines too early.

Fix this by using awk and adding the length difference between a colored
and uncolored version to the allowed length.

COLUMNS is a shell variable and thus needs exporting for `ENVIRON` to
see it in awk.
2023-01-17 16:33:53 +01:00
4c489c0d68 git:last-changed: Handle non-git-repo gracefully 2023-01-17 01:44:01 +01:00
99c99954e9 git:last-changed: Pass -p and smart --color flag
--color=auto breaks as `ls` is always piped. Test stdout of the whole
script to determine a sensible value for the flag.
2023-01-17 01:41:38 +01:00
9f0ffcb6ca git:last-changed: Support ANSI escape sequences
When passing --color to `ls` and the entry were colored, git would not
return a commit due to the escape sequences.
2023-01-17 01:39:43 +01:00
f317ed81c2 git: Add last-changed to mimic github file browser
List all files and directories but include the latest commits date and
subject, similar to the file browser in web-UIs of services like GitHub.
Also sort the entries by the commits date and time to see the most
recent changed files/folders at the bottom.
2023-01-17 01:38:17 +01:00
b93c4ee377 zsh:glog: Only pipe to fzf if stdout is a tty
This makes it easy to use `glog` in a pipe as replacement for `git log
--oneline`, for example to count the commits.
2022-12-27 04:27:21 +01:00
73c0864c8b git: Add https-and-ssh to setup origin
Sets up origin so that it fetches over https but pushes over ssh. This
way unlocking the ssh key is only needed when really necessary.
2022-12-01 01:27:28 +01:00
b22085777e git:checkout-worktree: Remove tmp dir on error
When the git-worktree call exits with an error we can delete the
temporary directory as nothing is in it.
2022-10-27 23:52:17 +02:00