From 4893da9523b8af34b7c619e0076139bd6255953c Mon Sep 17 00:00:00 2001 From: elkowar <5300871+elkowar@users.noreply.github.com> Date: Tue, 11 Aug 2020 17:45:41 +0200 Subject: [PATCH] add fish to nix --- files/.config/htop/htoprc | 2 +- .../nix-stuff/nixpkgs/config/fish-prompt.fish | 58 +++++++++ files/nix-stuff/nixpkgs/config/fish.nix | 111 ++++++++++++++++++ files/nix-stuff/nixpkgs/profiles/base.nix | 3 +- 4 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 files/nix-stuff/nixpkgs/config/fish-prompt.fish create mode 100644 files/nix-stuff/nixpkgs/config/fish.nix diff --git a/files/.config/htop/htoprc b/files/.config/htop/htoprc index 283a854..a4bc54c 120000 --- a/files/.config/htop/htoprc +++ b/files/.config/htop/htoprc @@ -1 +1 @@ -/nix/store/v0n44jjhbc1jh715dysni16gyskaf3g4-home-manager-files/.config/htop/htoprc \ No newline at end of file +/nix/store/mq1kmcv74gnyvvjsp5djgsd5p8hqsqx1-home-manager-files/.config/htop/htoprc \ No newline at end of file diff --git a/files/nix-stuff/nixpkgs/config/fish-prompt.fish b/files/nix-stuff/nixpkgs/config/fish-prompt.fish new file mode 100644 index 0000000..b21b023 --- /dev/null +++ b/files/nix-stuff/nixpkgs/config/fish-prompt.fish @@ -0,0 +1,58 @@ +function __fish_vi_mode_prompt_real + set -l turquoise (set_color 5fdfff) + set -l orange (set_color df5f00) + switch $fish_bind_mode + case insert + echo -n "─" + case default + echo -n $turquoise'N' + case visual + echo -n $orange'V' + case replace_one + echo -n $turquoise'R' + end +end + + +# Cache exit status +set -l last_status $status + +# Gruvboxy +set -l normal ( set_color normal) +set -l white ( set_color ebdbb2) +set -l turquoise ( set_color 83a598) +set -l orange ( set_color fe8019) +set -l aqua ( set_color 8ec07c) +set -l blue ( set_color 83a598) +set -l limegreen ( set_color b8bb26) +set -l purple ( set_color d3869b) + + +# Configure __fish_git_prompt +set -g __fish_git_prompt_char_stateseparator ' ' +set -g __fish_git_prompt_color 5fdfff +set -g __fish_git_prompt_color_flags df5f00 +set -g __fish_git_prompt_color_prefix white +set -g __fish_git_prompt_color_suffix white +set -g __fish_git_prompt_showdirtystate true +set -g __fish_git_prompt_showuntrackedfiles true +set -g __fish_git_prompt_showstashstate true +set -g __fish_git_prompt_show_informative_status true + +set -l current_user (whoami) +set -l vi_mode (__fish_vi_mode_prompt_real) +set -l git_prompt (__fish_git_prompt " (%s)") +#(pwd|sed "s=$HOME=~=") + +set -g fish_prompt_pwd_dir_length 1 + +echo -n $white'╭─'$vi_mode +echo -n $white'─'$aqua$current_user$white' in '$limegreen(prompt_pwd) +echo -n $turquoise$git_prompt +if test $last_status -gt 0 + echo -n ' '$orange$last_status +end +echo + +echo -n $white'╰─λ ' +echo -n $normal diff --git a/files/nix-stuff/nixpkgs/config/fish.nix b/files/nix-stuff/nixpkgs/config/fish.nix new file mode 100644 index 0000000..477ab7e --- /dev/null +++ b/files/nix-stuff/nixpkgs/config/fish.nix @@ -0,0 +1,111 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.elkowar.programs.fish; + myConf = import ../myConfig.nix; +in +{ + options.elkowar.programs.fish = { + enable = lib.mkEnableOption "Fish configuration"; + }; + config = { + programs.fish = { + enable = true; + functions = { + fish_prompt = builtins.readFile ./fish-prompt.fish; + fish_greeting = ""; + fish_mode_prompt = ""; + }; + + shellAliases = { + ls = "exa --icons"; + }; + + shellAbbrs = { + vim = "nvim"; + tsh = "trash"; + cxmonad = "nvim /home/leon/.xmonad/lib/Config.hs"; + cnix = "cd ~/nixpkgs/ && nvim home.nix && cd -"; + + gaa = "git add --all"; + gc = "git commit -m "; + gp = "git push"; + gs = "git status"; + }; + + plugins = + [ + { + name = "foreign-env"; + src = pkgs.fetchFromGitHub { + owner = "oh-my-fish"; + repo = "plugin-foreign-env"; + rev = "dddd9213272a0ab848d474d0cbde12ad034e65bc"; + sha256 = "00xqlyl3lffc5l0viin1nyp819wf81fncqyz87jx8ljjdhilmgbs"; + }; + } + ]; + + shellInit = '' + fish_vi_key_bindings + + #set -U FZF_TMUX 1 + set -U FZF_DEFAULT_COMMANDS "--filepath-word --cycle" + set -U FZF_PREVIEW_FILE_CMD "head -n 10 | bat --color=always --decorations=never" + set -U fish_greeting + + + #if status is-interactive + #and not set -q TMUX + #exec tmux + #end + + + [ (hostname) = "garnix" ] && alias rm='echo "rm is disabled. Please use trash instead."; false' + + function run_pipr + set -l commandline (commandline -b) + pipr --out-file /tmp/pipr_out --default "$commandline" + set -l result (cat /tmp/pipr_out) + commandline -r $result + commandline -f repaint + end + + bind \ca run_pipr + + function c + set -l result (/home/leon/scripts/conf) + commandline -r "$result" + commandline -f execute + end + + + function replace_with_yay + set -l cmd (commandline -b) + switch $cmd + case "*pacman*" + set edited (echo $cmd | sed 's/sudo //g' | sed 's/pacman/yay/g') + case "yay*" + set edited (echo $cmd | sed 's/yay/sudo pacman/g') + end + commandline -r "$edited" + commandline -f repaint + end + + bind \cy replace_with_yay + + # fff file manager cd on exit + function f + fff $argv + set -q XDG_CACHE_HOME; or set XDG_CACHE_HOME $HOME/.cache + cd (cat $XDG_CACHE_HOME/fff/.fff_d) + end + set -x EDITOR "nvim" + set -x FFF_TRASH_CMD "trash" # make fff's trash function use trash-cli + + fenv source '$HOME/.nix-profile/etc/profile.d/nix.sh' + set -g NIX_PATH "$HOME/.nix-defexpr/channels:$NIX_PATH" + fenv source "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" + ''; + }; + }; +} diff --git a/files/nix-stuff/nixpkgs/profiles/base.nix b/files/nix-stuff/nixpkgs/profiles/base.nix index d3f5ee7..287c32e 100644 --- a/files/nix-stuff/nixpkgs/profiles/base.nix +++ b/files/nix-stuff/nixpkgs/profiles/base.nix @@ -10,11 +10,12 @@ in #useZsh = lib.mkEnableOption }; - imports = [ ../config/tmux.nix ../config/generalConfig.nix ../config/zsh.nix ]; + imports = [ ../config/tmux.nix ../config/generalConfig.nix ../config/zsh.nix ../config/fish.nix ]; config = lib.mkIf cfg.enable { elkowar.programs.tmux.enable = true; elkowar.programs.zsh.enable = true; + elkowar.programs.fish.enable = true; elkowar.generalConfig.shellAliases = { gc = "git commit"; };