Extract a zsh mixin

This commit is contained in:
Oliver Davies 2025-04-05 11:07:32 +01:00
parent 6635e80bbf
commit 094874946a
10 changed files with 100 additions and 94 deletions

View file

@ -3,6 +3,5 @@
{
imports = [
./bin
./zsh
];
}

View file

@ -1,140 +0,0 @@
{
cl = "clear";
cs = "create-script";
daily = "run create-daily next";
rst = "rst2pdf";
st = "source .tmux";
sz = "source ~/.config/zsh/.zshrc";
ti = "timer";
uagr = "update-all-git-repos";
v = "nvim";
yt = "yt-dlp";
evl = "export-video-list";
vv = "cat ~/Documents/videos.json";
g = "git";
ga = "git add";
gan = "git add -N";
gap = "git add -p";
gb = "git branch";
gbl = "git blame";
gc = "git commit";
gca = "git commit --amend";
gcan = "git commit --amend --no-edit";
gcl = "git clone";
gcm = "git commit -m";
gco = "git checkout";
gcob = "git checkout -b";
gd = "git diff";
gds = "git diff --staged";
gf = "git fetch";
gfa = "git fetch --all";
gl = "git log";
glo = "git log --oneline";
gls = "git log --stat";
gm = "git merge";
gmf = "git merge --ff";
gmnf = "git merge --no-ff";
gp = "git push";
gpa = "git push acquia";
gpam = "git push acquia main";
gpap = "git push acquia HEAD:production";
gpl = "git pull";
gplr = "git pull --rebase";
gpo = "git push origin";
gpom = "git push origin main";
gr = "git rebase";
gra = "git rebase --abort";
grc = "git rebase --continue";
gri = "git rebase -i";
gs = "git status";
gsh = "git show";
gst = "git stash";
gstp = "git stash pop";
gt = "git tag";
# tmux
ta = "tmux attach";
tl = "tmux list-sessions";
tk = "tmux kill-session";
# Docker and Docker Compose.
dk = "docker";
dkp = "docker ps";
dkpa = "docker ps -a";
dkpaq = "docker ps -a -q";
dkb = "docker build -t";
dks = "docker start";
dkt = "docker stop";
dkrm = "docker rm";
dkri = "docker rmi";
dke = "docker exec -ti";
dkl = "docker logs -f";
dki = "docker images";
dkpu = "docker pull";
dkph = "docker push";
dkbnc = "docker build --no-cache -t";
dkr = "docker run --rm";
dkrti = "docker run --rm -ti";
dkc = "docker compose";
dkcb = "docker compose build";
dkcu = "docker compose up";
dkclean = "docker ps -q -a -f status=exited | xargs -r docker rm && docker images -q -f dangling=true | xargs -r docker rmi";
# Nix and direnv.
dea = "direnv allow";
dee = "direnv edit";
nxf = "nix flake";
nxfc = "nix flake check";
nxfs = "nix flake show";
nxfu = "nix flake update";
nxr = "nix run nixpkgs#%";
nxs = "nix shell nixpkgs#%";
# run scripts.
r = "run";
rc = "run composer";
rcda = "run composer dump-autoload";
rci = "run composer install";
rcr = "run composer require";
rcu = "run composer update";
rd = "run drush";
rdce = "run drush config:export -y";
rdci = "run drush config:import -y";
rdcr = "run drush cache:rebuild";
rdscr = "run drush php:script";
rduli = "run drush uli";
rdup = "run drush updatedb -y";
rpub = "run publish";
rt = "run test";
nah = "git reset --hard; git clean -fd";
wip = "git commit -m wip";
dv = "devenv";
dvi = "devenv info";
dvp = "devenv processes";
dvs = "devenv shell";
dvt = "devenv tasks";
dvu = "devenv up";
c = "composer";
ci = "composer install";
cr = "composer require";
crd = "composer require drupal/%";
cu = "composer update";
cul = "composer update --lock";
cw = "composer why";
cwn = "composer why-not";
d = "drush";
dce = "drush config:export -y";
dci = "drush config:import -y";
dcr = "drush cache:rebuild";
den = "drush pm:enable -y";
deu = "drush pm:uninstall";
dscr = "drush php:script";
duli = "drush uli";
dup = "drush updatedb -y";
}

View file

@ -1,14 +0,0 @@
{ config, ... }:
{
"$" = "";
"-" = "cd -";
".." = "cd ..";
"..." = "cd ../..";
"...." = "cd ../../..";
"....." = "cd ../../../..";
run = "./run";
tag = "tag-release";
vss = "LC_ALL=C sort --unique ${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/nixos-config/modules/home-manager/cli/neovim/config/spell/en.utf-8.adddotfiles/nvim/spell/en.utf-8.add --output ${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/nixos-config/modules/home-manager/cli/neovim/config/spell/en.utf-8.add";
wt = "git worktree";
}

View file

@ -1,93 +0,0 @@
{ config, pkgs, ... }:
{
programs.zsh = {
enable = true;
enableCompletion = true;
syntaxHighlighting.enable = true;
zsh-abbr = {
enable = true;
abbreviations = import ./abbreviations.nix;
globalAbbreviations = import ./global-abbreviations.nix;
};
dotDir = ".config/zsh";
shellAliases = (import ./aliases.nix { inherit config; });
localVariables = {
ABBR_SET_EXPANSION_CURSOR = 1;
};
initExtra = ''
if [[ -z "$DISPLAY" ]] && [[ "$(tty)" == "/dev/tty1" ]]; then
exec startx &>/dev/null
fi
# suffix
alias -s gz="tar -tf"
alias -s {html,HTML}="background firefox"
alias -s {jpg,JPG,png,PNG}="background okular"
alias -s {pdf,PDF}="background okular"
alias -s {zip,ZIP}="unzip -l"
git() {
case "$1" in
clone)
shift
local repo_url="$1"
local repo_path="''${2:-}"
if [ -n "$TARGET_DIR" ]; then
command git clone "$repo_url" "$repo_path"
else
command git clone "$repo_url"
repo_path=$(basename "$repo_url" .git)
fi
${pkgs.tmux-sessionizer}/bin/tmux-sessionizer "$repo_path"
;;
root)
shift
local ROOT="$(${pkgs.git}/bin/git rev-parse --show-toplevel 2> /dev/null || echo -n .)"
if [[ $# == 0 ]]; then
cd "''${ROOT}"
else
(cd "''${ROOT}" && eval "''${@}")
fi
;;
*)
${pkgs.git}/bin/git "''${@}"
;;
esac
}
mbsync() {
${pkgs.isync}/bin/mbsync --config "${config.xdg.configHome}/isync/mbsyncrc" "''${@}"
}
ttyper() {
command ${pkgs.ttyper}/bin/ttyper --language english1000 --words 50 "''${@}"
}
yt-dlp() {
command yt-dlp --paths ~/Videos "$@"
}
bindkey -s ^f "tmux-sessionizer\n"
bindkey -s ^v "nvim\n"
setopt auto_cd
setopt auto_pushd
setopt pushd_ignore_dups
setopt pushdminus
'';
};
}

View file

@ -1,14 +0,0 @@
{
A1 = "| awk '{print $1}'";
C = "| xclip -sel clip";
Fj = "| jq .";
Fy = "| yq .";
G = "| grep";
GH = "| grep HTTP";
Gi = "| grep -i";
H2 = "| head -n 20";
H = "| head";
L = "| less";
V = "| nvim -";
X = "| xargs -I1";
}