Commit Graph

545 Commits

Author SHA1 Message Date
5c51bd87c4 zsh:completion: Autoload and run bashcompinit
zshcompsys(1):

> The function bashcompinit provides compatibility with bash's
> programmable completion system. When run it will define the functions,
> compgen and complete which correspond to the bash builtins with the
> same names. It will then be possible to use completion specifications
> and functions written for bash.
2022-06-23 23:56:50 +02:00
15f4bac670 zprofile: Exit after tmux instead of exec-ing
Instead of exec-ing the tmux process, run it normally and exit
afterwards. Otherwise the zlogout is not read as mentioned a couple of
lines above and in `zsh(1)`:

> However, if the shell terminates due to exec'ing another process, the
> logout files are not read.
2022-06-23 23:56:34 +02:00
3b29820957 zprofile: Use exec when attaching to tmux
When connected over ssh and attaching to/creating a tmux session, the
shell should `exec` the tmux command so that detaching from the session
automatically also closes the ssh connection.

If something should happen and the `tmux` command bricks the remote
shell this can fixed by logging in with:

    ssh [destination] zsh -dfi
2022-06-23 23:55:53 +02:00
79c7cdf416 git:checkout-worktree: Escape slashes in branch
Escape slashes in the branch name before passing it to `mktemp`.
Otherwise it would complain with:

    mktemp: invalid suffix [...], contains directory separator
2022-06-23 23:54:13 +02:00
be1bd6f08d git:checkout-worktree: Add scripted-use examples 2022-03-31 17:56:07 +02:00
ab53cff2a3 git:checkout-worktree: Update description
Add description in one sentence and use cases for this.
Remove sentence about removing `TEMP_DIR` that is outdated since:
5a8b5ffd21 ("git:checkout-worktree: Use `mktemp` template")
2022-03-31 17:48:05 +02:00
71450ad133 git:checkout-worktree: Fix endless loop
Fix endless loop when commands are passed via stdin that result in the
worktree not being removable. Fix by then dropping into an interactive
shell.
2022-03-31 17:28:05 +02:00
399b571e85 git:checkout-worktree: Refactor into one loop 2022-03-31 17:11:59 +02:00
a60c955d3d git:checkout-worktree: Set err_return + no_unset
If anything happens abnormally, return early and leave it to the user to
fix things.
2022-03-31 16:57:46 +02:00
d56979362a git:checkout-worktree: s/REPO_DIR/WORKTREE_PATH/ 2022-03-31 16:15:46 +02:00
5a8b5ffd21 git:checkout-worktree: Use mktemp template
Use a template that directly includes the repository name and the branch
checked out. This makes finding and deleting the worktree directory if
anything goes wrong a lot easier.

Checkout the worktree directly in the temporary directory. With that
`TEMP_DIR` becomes obsolete.
2022-03-31 16:00:47 +02:00
976d3f9000 git:checkout-worktree: Mention non-interactive use 2022-03-31 15:43:49 +02:00
02a0e17bcb git:checkout-worktree: Fix exit when not in repo
Fix the exit condition when the function is called outside of a git
repository.
Use zsh's `:t` History Expansion Modifier, as `$?` does not keep `git
rev-parse`'s exit code, but rather `basename`'s.
2022-03-31 15:33:53 +02:00
eb323992dc git:checkout-worktree: Keep the shell's exit code
Exit with the exit code of the last spawned shell.
2022-03-31 15:29:53 +02:00
b44ff72210 git:checkout-worktree: Rephrase description 2022-03-31 15:27:29 +02:00
9968edaf09 zsh: Make git-checkout-worktree autoloadable
Transform `git-checkout-worktree` into an autoloadable function.
2022-03-31 15:19:56 +02:00
fa8a6b10fa zsh:alias:git: Add diff --staged and rebase -i 2022-03-31 00:53:26 +02:00
74e72c18c6 zsh:alias: Sort git aliases + Add comment 2022-03-31 00:51:35 +02:00
0ba0c04c56 zsh: Use $+commands[] instead of command -v 2022-03-31 00:46:46 +02:00
0671f028e7 zsh:comp: Rephrase completion copy comment
Add note to useful bindings.
2022-03-30 03:01:20 +02:00
541ff31af4 zsh:comp: Don't sort git-{rebase,show,signoff}
Do not sort completion functions of git-{rebase,show,signoff}.
2022-03-30 03:01:20 +02:00
e024ca9f0a zsh:auto,comp: Add git-signoff function
Add `git-signoff` to signoff commits in given range.
Reuse the `_git-rebase` completion function for `git-signoff`.
2022-03-30 03:00:48 +02:00
d4350dbd7c zsh:auto:git-submodule-rm: Keep git exit code
Split `toplevel` definition and assignment as the `local` builtin has
it's own exit code. Thus the function previously did not return if the
`PWD` was not in a git repo.
2022-03-30 03:00:46 +02:00
4ae8a2db83 zsh:funcs: Add pgrep that uses ps aux | grep
I sometimes find `pgrep` not matching the processes I am searching for,
but `ps aux | grep ...` did not disappoint yet.
2022-03-30 01:43:17 +02:00
5df9e4d6ee zsh,vim: Add WIP Zettelkasten tooling
Add `zk`, an autoloadable function that creates a new zettel after a
template in the right directory.
Add `zettel` vim ftplugin.
2022-03-28 23:48:51 +02:00
11530608c9 zsh:p10k: Reenable time segment
I disabled that in the past but want have it again.
2022-03-10 14:57:17 +01:00
72c616d378 zsh:p10k: Reapply custom changes
I wanted to have them standalone in a commit once for better
transparency instead of reapplying them before committing the updated
theme in the last commit:
529c41abcf ("zsh:p10k: Reset to `p10k configure`")
2022-03-10 14:56:47 +01:00
529c41abcf zsh:p10k: Reset to p10k configure
Rerun the p10k configurator with the current version.
2022-03-10 14:56:24 +01:00
1ff96687d3 zsh:syntax-highlighting: Update to include 0ddb1a8
Update zsh-syntax-highlighting to include 0ddb1a8d5120 as this fixes a
highlighting bug with zsh-autosuggestions introduced with zsh 5.8.1.
See following issues:
 - 662 in zsh-autosuggestions
 - 857 in zsh-syntax-highlighting
2022-02-28 12:11:44 +01:00
020a132c13 zsh:alias: Alias gp to git push
As I mostly fetch and then merge or rebase instead of pulling `git push`
can have the shorter variant of its alias.
2022-02-20 23:52:13 +01:00
6b2a03222b zsh:keys: Bind ^3 to pound-insert 2022-02-20 23:48:59 +01:00
0ed5e711bf zsh:alias: Add gf for git fetch 2022-02-17 16:54:28 +01:00
2b02ee50b4 zsh:zprofile: Use $XDG_CONFIG_HOME for tmux config 2022-02-17 15:54:02 +01:00
5794af1c52 zsh:autoload:git-track: Make more portable
Some distributions ship older versions of `column` that do not have the
flags `-dNLO`. This is a workaround around this limitation that creates
the same output using other tools.
2022-02-17 15:40:51 +01:00
a14478f758 zsh: Add _page_readme_chpwd_handler()
Open READMEs in a pager when going into a directory that contains one.
2022-02-07 04:22:32 +01:00
771232217e zsh:zprofile: Always export $LESS* variables 2022-02-03 18:31:10 +01:00
98e9c8abed less: Display ANSI colors by default 2022-02-03 18:31:00 +01:00
fe16087da4 less: Enable mouse-support 2022-02-03 18:30:59 +01:00
00de841771 zsh:zprofile: Do not set $MANPAGER to nvim
Do not set `MANPAGER` to `nvim` as `nvim-man` is used already and in the
case that it does not open `nvim` I want to use `less` as **pager**.
This makes it possible to use `man -- <page>` as 'hack' to view the page
in `less` for example if a real pager is desired because of the loading
time (e.g. `zshall`).
2022-02-03 18:30:57 +01:00
6d64a0e609 zsh:funcs:nvim-man: Format nvim commands 2022-02-03 18:30:56 +01:00
dd7302f311 zsh:funcs:nvim-man: Use subjunctive in comment 2022-02-03 18:30:54 +01:00
5312e42a09 zsh:funcs:nvim-man: Use [[ for option check
"${1#-}" is not properly parsed in `((` when long options containing a
`=` are passed (`bad math expression: operand expected`).
2022-02-03 18:30:42 +01:00
3dbffbc08e zsh:funcs:nvim-man: Check if stdout is terminal
If `stdout` is not a terminal, `command man` should be used as `nvim`
won't work.
2022-02-03 18:30:39 +01:00
46605c7a84 zsh:funcs:nvim-man: Use man if option is passed
If an option without arguments like `--version` is passed, `nvim-man`
should use `command man` as well.
2022-02-03 18:30:38 +01:00
e55652fd44 zsh:funcs:nvim-man: Move page existence check call
Check for the existence of the page only if `nvim` would be executed.
2022-02-03 18:30:36 +01:00
1be26adfc9 zsh:funcs:nvim-man: Use minimal config + scrolloff
Load only the `man.vim` plugin, nothing else. This should speed up the
startup a bit. It will never be as fast as `less` though, as it loads
the whole file first.
2022-02-03 18:29:37 +01:00
9817ef3f63 zsh:autoload:crypt-*: Rename to crypt-{open,close}
Rename `crypt-{,u}mount` to `crypt-{open,close}` as in these functions a
lot more happens than just {,un}mounting.
2022-02-01 01:18:15 +01:00
eac6953150 zsh:autoload:crypt-*mount: Get basename natively
Use zsh's builtin history expansion modifiers `:t` to get the basename
of the block device.
2022-02-01 01:15:42 +01:00
7f52c7a4cb git,zsh:autoload: Move git-track into own function
Move `git-track` into its own autoloadable function.
This way it is
better maintainable as in one-liner format and brings the possibility of
having more complexity (e.g. for better portability).
By that it is also now executable as `git-track` as well as `git track`
as before.
2022-01-31 12:50:54 +01:00
271f5bcf25 zsh:funcs:crypt-*mount: Set pipe_fail
Set `pipe_fail` so that if for example the `grep` fails while getting
`$mount_point`, the function returns early.
2022-01-30 00:37:13 +01:00