diff --git a/home/programs/terminal/default.nix b/home/programs/terminal/default.nix index 63b0638..5159b60 100644 --- a/home/programs/terminal/default.nix +++ b/home/programs/terminal/default.nix @@ -1,3 +1,5 @@ _: { - imports = [ ]; + imports = [ + ./shell + ]; } diff --git a/home/programs/terminal/shell/default.nix b/home/programs/terminal/shell/default.nix new file mode 100644 index 0000000..0d5d08b --- /dev/null +++ b/home/programs/terminal/shell/default.nix @@ -0,0 +1,5 @@ +_: { + imports = [ + ./zsh + ]; +} diff --git a/home/programs/terminal/shell/zsh/aliases.nix b/home/programs/terminal/shell/zsh/aliases.nix new file mode 100644 index 0000000..49ae984 --- /dev/null +++ b/home/programs/terminal/shell/zsh/aliases.nix @@ -0,0 +1,38 @@ +{ config, ... }: +let + username = config.myOptions.system.username; +in +{ + home-manager.users.${username} = { + programs.zsh.shellAliases = { + # I'm not the greatest typist + sl = "ls"; + mdkir = "mkdir"; + soruce = "source"; + suod = "sudo"; + sduo = "sudo"; + + # Directory changing + ".." = "cd .."; + "..." = "cd ../../"; + "...." = "cd ../../../"; + "....." = "cd ../../../../"; + ".2" = "cd ../../"; + ".3" = "cd ../../../"; + ".4" = "cd ../../../../"; + ".5" = "cd ../../../../../"; + + # Files/Directories utilities + mkdir = "mkdir -p"; + md = "mkdir"; + fhere = "find . -name"; + rr = "rm -r"; + rf = "rm -f"; + rrf = "rm -rf"; + vimdiff = "nvim -d"; + + # Expand aliases from sudo + sudo = "sudo "; + }; + }; +} diff --git a/home/programs/terminal/shell/zsh/default.nix b/home/programs/terminal/shell/zsh/default.nix new file mode 100644 index 0000000..b439c12 --- /dev/null +++ b/home/programs/terminal/shell/zsh/default.nix @@ -0,0 +1,68 @@ +{ config, pkgs, ... }: +let + username = config.myOptions.system.username; + hmCfg = config.home-manager.users.${username}; +in +{ + imports = [ + ./plugins.nix + ./aliases.nix + ]; + + programs.zsh.enable = true; + users.users.${username}.shell = pkgs.zsh; + + home-manager.users.${username} = { + programs.zsh = { + enable = true; + dotDir = ".config/zsh"; + enableCompletion = true; + enableAutosuggestions = true; + autocd = true; + + history = { + # share history across different running zsh session + share = true; + + # don't clutter $HOME + path = "${hmCfg.xdg.dataHome}/zsh/zsh_history"; + + # save timestamps to histfile + extended = true; + + save = 120000; + size = 100000; + + # If the internal history needs to be trimmed to add the current command line, + # this will cause the oldest history event that has a duplicate to be lost before + # losing a unique event from the list. You should set the value of history size + # to a larger number than the save size in order to give some room for the duplicated + # events, otherwise this option will behave just like ignoreDups once history fills + # up with unique events. + expireDuplicatesFirst = true; + + # If a new command line being added to the history list duplicates an older one, + # the older command is removed from the list (even if it is not the previous event). + ignoreAllDups = true; + + # Don't track command lines in the history list when the first character on the line + # is a space, or when one of the expanded aliases contains a leading space. Note that + # the command lingers in the internal session history until the next command is entered + # before it vanishes, allowing you to briefly reuse or edit the line. + ignoreSpace = true; + }; + + # dirhashes are easy aliases to commonly used directories + # allowing use like `cd ~dl`, going to $HOME/Downloads + dirHashes = { + dl = "$HOME/Downloads"; + media = "$HOME/Media"; + pics = "$HOME/Media/Pictures"; + vids = "$HOME/Media/Videos"; + mems = "$HOME/Media/Memes"; + screenshots = "$HOME/Media/Pictures/Screenshots"; + dots = "$HOME/dots"; + }; + }; + }; +} diff --git a/home/programs/terminal/shell/zsh/plugins.nix b/home/programs/terminal/shell/zsh/plugins.nix new file mode 100644 index 0000000..4b97a8a --- /dev/null +++ b/home/programs/terminal/shell/zsh/plugins.nix @@ -0,0 +1,41 @@ +{ config, pkgs, ... }: +let + username = config.myOptions.system.username; + inherit (pkgs) fetchFromGitHub; +in +{ + + home-manager.users.${username} = { + programs.zsh.plugins = [ + { + name = "zsh-nix-shell"; + src = pkgs.zsh-nix-shell; + file = "share/zsh-nix-shell/nix-shell.plugin.zsh"; + } + { + name = "zsh-vi-mode"; + src = pkgs.zsh-vi-mode; + file = "share/zsh-vi-mode/zsh-vi-mode.plugin.zsh"; + } + { + name = "fast-syntax-highlighting"; + src = "${pkgs.zsh-fast-syntax-highlighting}/share/zsh/site-functions"; + } + { + name = "zsh-autosuggestions"; + src = pkgs.zsh-autosuggestions; + file = "share/zsh-autosuggestions/zsh-autosuggestions.zsh"; + } + { + name = "zsh-autopair"; + file = "zsh-autopair.plugin.zsh"; + src = fetchFromGitHub { + owner = "hlissner"; + repo = "zsh-autopair"; + rev = "2ec3fd3c9b950c01dbffbb2a4d191e1d34b8c58a"; + hash = "sha256-Y7fkpvCOC/lC2CHYui+6vOdNO8dNHGrVYTGGNf9qgdg="; + }; + } + ]; + }; +}