simplify abbr creation
This commit is contained in:
@ -14,26 +14,40 @@ in {
|
|||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
programs.fish = {
|
programs.fish = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
|
# TODO:
|
||||||
# functions = {};
|
# functions = {};
|
||||||
|
|
||||||
|
# TODO:
|
||||||
# plugins = [];
|
# plugins = [];
|
||||||
|
|
||||||
shellAbbrs = let
|
shellAbbrs = let
|
||||||
|
# Only add " | bat" if bat is installed
|
||||||
batify = command: command + (optionalString config.programs.bat.enable " | bat");
|
batify = command: command + (optionalString config.programs.bat.enable " | bat");
|
||||||
batify2 = command: args: command + (optionalString config.programs.bat.enable (" | bat " + args));
|
# Same as above but with args for bat
|
||||||
|
batifyWithArgs = command: args: command + (optionalString config.programs.bat.enable (" | bat " + args));
|
||||||
|
|
||||||
|
# NOTE: These can be used for my config.modules and for HM config.programs, as both of these add the package to home.packages
|
||||||
|
hasHomePackage = package: (contains config.home.packages package);
|
||||||
|
# Only add fish abbr if package is installed
|
||||||
|
abbrify = package: abbr: (optionalAttrs (hasHomePackage package) abbr);
|
||||||
in mkMerge [
|
in mkMerge [
|
||||||
# Default abbrs, always available
|
# Default abbrs, always available
|
||||||
{
|
{
|
||||||
|
# Shell basic
|
||||||
c = "clear";
|
c = "clear";
|
||||||
q = "exit";
|
q = "exit";
|
||||||
h = batify "history";
|
|
||||||
|
# Fish
|
||||||
|
h = batifyWithArgs "history" "-l fish"; # -l fish sets syntax highlighting to fish
|
||||||
|
listabbrs = batifyWithArgs "abbr" "-l fish";
|
||||||
|
|
||||||
# tools
|
# tools
|
||||||
cd = "z";
|
cd = "z"; # zoxide for quickjump to previously visited locations
|
||||||
# cp = "cp -puri"; # TODO: Is rsync a good replacement?
|
mkdir = "mkdir -p"; # also create parents (-p)
|
||||||
mkdir = "mkdir -p";
|
|
||||||
blk = batify "lsblk -o NAME,LABEL,UUID,FSTYPE,SIZE,FSUSE%,MOUNTPOINT,MODEL";
|
blk = batify "lsblk -o NAME,LABEL,UUID,FSTYPE,SIZE,FSUSE%,MOUNTPOINT,MODEL";
|
||||||
grep = "grep --color=auto -E";
|
grep = "grep --color=auto -E"; # grep with extended regex
|
||||||
watch = "watch -d -c -n -0.5";
|
watch = "watch -d -c -n -0.5";
|
||||||
listabbrs = batify2 "abbr" "-l fish";
|
|
||||||
|
|
||||||
# systemd
|
# systemd
|
||||||
failed = "systemctl --failed";
|
failed = "systemctl --failed";
|
||||||
@ -42,35 +56,38 @@ in {
|
|||||||
uniterrors = "journalctl -xb --unit=";
|
uniterrors = "journalctl -xb --unit=";
|
||||||
useruniterrors = "journalctl -xb --user-unit=";
|
useruniterrors = "journalctl -xb --user-unit=";
|
||||||
|
|
||||||
|
# ssh locations
|
||||||
xxhamster = "TERM=ansi ssh christoph@217.160.142.51";
|
xxhamster = "TERM=ansi ssh christoph@217.160.142.51";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Abbrs only available if package is installed
|
# Abbrs only available if package is installed
|
||||||
(optionalAttrs (contains config.home.packages pkgs.lazygit) { lg = "lazygit"; })
|
(abbrify pkgs.btop { top = "btop"; })
|
||||||
(optionalAttrs (contains config.home.packages pkgs.gping) { ping = "gping"; })
|
(abbrify pkgs.duf {
|
||||||
(optionalAttrs (contains config.home.packages pkgs.duf) { df = "duf"; })
|
df = "duf";
|
||||||
(optionalAttrs (contains config.home.packages pkgs.gdu) { du = "gdu"; })
|
disksummary = "duf";
|
||||||
(optionalAttrs config.programs.btop.enable { top = "btop"; })
|
})
|
||||||
(optionalAttrs (contains config.home.packages pkgs.fzf) { fz = "fzf --preview 'bat --color=always --style=numbers --line-range=:500 {}'"; })
|
(abbrify pkgs.exa {
|
||||||
(optionalAttrs config.modules.ranger.enable { r = "ranger --choosedir=$HOME/.rangerdir; set LASTDIR (cat $HOME/.rangerdir); cd $LASTDIR"; })
|
ls = "exa --color always --group-directories-first -F --git --icons"; # color-ls
|
||||||
(optionalAttrs config.programs.git.enable {
|
lsl = "exa --color always --group-directories-first -F -l --git --icons";
|
||||||
|
lsa = "exa --color always --group-directories-first -F -l -a --git --icons";
|
||||||
|
tre = "exa --color always --group-directories-first -F -T -L 2 ---icons";
|
||||||
|
})
|
||||||
|
(abbrify pkgs.fd { find = "fd"; })
|
||||||
|
(abbrify pkgs.fzf { fuzzy = "fzf --preview 'bat --color=always --style=numbers --line-range=:500 {}'"; })
|
||||||
|
(abbrify pkgs.gdu {
|
||||||
|
du = "gdu";
|
||||||
|
storageanalysis = "gdu";
|
||||||
|
})
|
||||||
|
(abbrify pkgs.git {
|
||||||
gs = "git status";
|
gs = "git status";
|
||||||
gcm = "git commit -m";
|
gcm = "git commit -m";
|
||||||
ga = "git add";
|
ga = "git add";
|
||||||
glg = "git log --graph --decorate --oneline";
|
glg = "git log --graph --decorate --oneline";
|
||||||
gcl = "git clone";
|
gcl = "git clone";
|
||||||
})
|
})
|
||||||
(optionalAttrs (contains config.home.packages pkgs.rsync) {
|
(abbrify pkgs.gping { ping = "gping"; })
|
||||||
cp = "rsync -ahv --inplace --partial --info=progress2";
|
(abbrify pkgs.lazygit { lg = "lazygit"; })
|
||||||
rsync = "rsync -ahv --inplace --partial --info=progress2";
|
(abbrify pkgs.protonvpn-cli {
|
||||||
})
|
|
||||||
(optionalAttrs config.programs.exa.enable {
|
|
||||||
ls = "exa --color always --group-directories-first -F --git --icons"; # color-ls
|
|
||||||
lsl = "exa --color always --group-directories-first -F -l --git --icons";
|
|
||||||
lsa = "exa --color always --group-directories-first -F -l -a --git --icons";
|
|
||||||
tre = "exa --color always --group-directories-first -F -T -L 2 ---icons";
|
|
||||||
})
|
|
||||||
(optionalAttrs (contains config.home.packages pkgs.protonvpn-cli) {
|
|
||||||
vpnat = "protonvpn-cli c --cc at";
|
vpnat = "protonvpn-cli c --cc at";
|
||||||
vpnch = "protonvpn-cli c --cc ch";
|
vpnch = "protonvpn-cli c --cc ch";
|
||||||
vpnlu = "protonvpn-cli c --cc lu";
|
vpnlu = "protonvpn-cli c --cc lu";
|
||||||
@ -79,7 +96,13 @@ in {
|
|||||||
vpnkr = "protonvpn-cli c --cc kr";
|
vpnkr = "protonvpn-cli c --cc kr";
|
||||||
vpnoff = "protonvpn-cli d";
|
vpnoff = "protonvpn-cli d";
|
||||||
})
|
})
|
||||||
(optionalAttrs config.programs.yt-dlp.enable {
|
(abbrify pkgs.ranger { r = "ranger --choosedir=$HOME/.rangerdir; set LASTDIR (cat $HOME/.rangerdir); cd $LASTDIR"; })
|
||||||
|
(abbrify pkgs.rsync {
|
||||||
|
cp = "rsync -ahv --inplace --partial --info=progress2";
|
||||||
|
rsync = "rsync -ahv --inplace --partial --info=progress2";
|
||||||
|
})
|
||||||
|
(abbrify pkgs.sd { sed = "sd"; })
|
||||||
|
(abbrify pkgs.yt-dlp {
|
||||||
mp4 = "yt-dlp -f 'bv*[ext=mp4]+ba[ext=m4a]/b[ext=mp4] / bv*+ba/b' --recode-video mp4"; # the -f options are yt-dlp defaults
|
mp4 = "yt-dlp -f 'bv*[ext=mp4]+ba[ext=m4a]/b[ext=mp4] / bv*+ba/b' --recode-video mp4"; # the -f options are yt-dlp defaults
|
||||||
mp3 = "yt-dlp -f 'ba' --extract-audio --audio-format mp3";
|
mp3 = "yt-dlp -f 'ba' --extract-audio --audio-format mp3";
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user