about summary refs log tree commit diff
path: root/home/shell
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2023-05-05 19:41:58 -0700
committerFranck Cuny <franck@fcuny.net>2023-05-05 19:41:58 -0700
commit43da9edb4598eef509c481ae0b305384418c45de (patch)
treea0ad614c90102757143e026e4fe1806431a3dbf4 /home/shell
parentprofiles/default: users are immutable (diff)
downloadworld-43da9edb4598eef509c481ae0b305384418c45de.tar.gz
home/profiles: move (almost) all modules to profiles
This is a major refactor, similar to what was done for the hosts, but in
a single commit.
Diffstat (limited to 'home/shell')
-rw-r--r--home/shell/aliases.nix10
-rw-r--r--home/shell/default.nix25
-rw-r--r--home/shell/fish/default.nix20
-rw-r--r--home/shell/fish/functions/find-ssh-agent.fish20
-rw-r--r--home/shell/fish/functions/new-go-project.fish27
-rw-r--r--home/shell/fish/functions/nix-rebuild-hm.fish4
-rw-r--r--home/shell/fish/functions/nix-rebuild-host.fish4
-rw-r--r--home/shell/fish/interactive.fish8
-rw-r--r--home/shell/fish/login.fish10
-rw-r--r--home/shell/zsh/completion-style.zsh42
-rw-r--r--home/shell/zsh/default.nix48
-rw-r--r--home/shell/zsh/new-go-project.zsh19
-rw-r--r--home/shell/zsh/options.zsh27
-rw-r--r--home/shell/zsh/prompt.zsh17
-rw-r--r--home/shell/zsh/tmux.zsh9
15 files changed, 0 insertions, 290 deletions
diff --git a/home/shell/aliases.nix b/home/shell/aliases.nix
deleted file mode 100644
index 49d1725..0000000
--- a/home/shell/aliases.nix
+++ /dev/null
@@ -1,10 +0,0 @@
-{
-  ll = "ls -l --color=auto";
-  lt = "ls -ltrh --color=auto";
-  la = "ls -ltrha --color=auto";
-  pkgsearch = "nix search nixpkgs";
-  hms = "home-manager switch --flake .";
-  nr = "sudo nixos-rebuild switch --flake .";
-  flup = "nix flake update --commit-lock-file";
-  dhcp-leasese = "xdg-open http://192.168.6.1:8067/";
-}
diff --git a/home/shell/default.nix b/home/shell/default.nix
deleted file mode 100644
index f34d997..0000000
--- a/home/shell/default.nix
+++ /dev/null
@@ -1,25 +0,0 @@
-{ config, lib, pkgs, ... }:
-
-with lib;
-let
-  cfg = config.my.home.shell;
-  aliases = import ./aliases.nix;
-in
-{
-  options.my.home.shell = {
-    name = mkOption {
-      default = "zsh";
-      type = types.enum [ "fish" "zsh" ];
-      example = "zsh";
-    };
-    aliases = mkOption {
-      default = aliases;
-      description = ''
-        A wrapper for shellAliases for zsh and fish
-      '';
-      type = types.attrsOf types.str;
-    };
-  };
-
-  imports = [ ./fish ./zsh ];
-}
diff --git a/home/shell/fish/default.nix b/home/shell/fish/default.nix
deleted file mode 100644
index f3e41d9..0000000
--- a/home/shell/fish/default.nix
+++ /dev/null
@@ -1,20 +0,0 @@
-{ config, lib, pkgs, ... }:
-let
-  cfg = config.my.home.shell;
-  aliases = config.my.home.shell.aliases;
-in
-{
-  config = lib.mkIf (cfg.name == "fish") {
-    programs.fish = {
-      enable = true;
-      shellAliases = aliases;
-      interactiveShellInit = builtins.readFile ./interactive.fish;
-      loginShellInit = builtins.readFile ./login.fish;
-    };
-
-    xdg.configFile."fish/functions" = {
-      source = ./functions;
-      recursive = true;
-    };
-  };
-}
diff --git a/home/shell/fish/functions/find-ssh-agent.fish b/home/shell/fish/functions/find-ssh-agent.fish
deleted file mode 100644
index 9e2de8d..0000000
--- a/home/shell/fish/functions/find-ssh-agent.fish
+++ /dev/null
@@ -1,20 +0,0 @@
-function find-ssh-agent --description "find or run ssh-agent"
-    # let's avoid storing the agent's socket under /tmp
-    set -l ssh_auth_sock $XDG_RUNTIME_DIR/ssh-agent.sock
-
-    if set -q SSH_AGENT_PID; and set -q SSH_AUTH_SOCK
-        # if variables already defined, then try to connect to agent
-        ssh-add -l &>/dev/null
-        test $status -ne 2; and return
-    end
-
-    set -l user_id (id -u)
-    set -l ssh_agent_pid (pgrep --exact --newest --uid $user_id ssh-agent)
-
-    if test -S $ssh_auth_sock
-        set --global --export SSH_AUTH_SOCK $ssh_auth_sock
-        set --global --export SSH_AGENT_PID $ssh_agent_pid
-    else
-        eval (ssh-agent -c -a $ssh_auth_sock)
-    end
-end
diff --git a/home/shell/fish/functions/new-go-project.fish b/home/shell/fish/functions/new-go-project.fish
deleted file mode 100644
index e00a036..0000000
--- a/home/shell/fish/functions/new-go-project.fish
+++ /dev/null
@@ -1,27 +0,0 @@
-function new-go-project --description "create a new go project"
-    set -l project_name $argv[1]
-
-    echo "> creating $project_name"
-    cd ~/workspace/
-    mkdir $project_name
-    cd $project_name
-
-    echo "> running `git init'"
-    git init .
-
-    echo "> setting the default template for go projects"
-    nix flake init -t ~/workspace/world/templates#go
-    direnv allow
-
-    echo "> creating initial commit, touch your yubikey"
-    git add .
-    git commit -m 'initial commit'
-
-    echo "> pushing to https://git.fcuny.net/fcuny/$project_name"
-    git remote add origin https://git.fcuny.net/fcuny/$project_name
-    git push origin --all
-
-    echo "> enabling drone CI for the repository"
-    drone --token (pass credentials/ci.fcuny.net) repo sync
-    drone --token (pass credentials/ci.fcuny.net) repo enable fcuny/$project_name
-end
diff --git a/home/shell/fish/functions/nix-rebuild-hm.fish b/home/shell/fish/functions/nix-rebuild-hm.fish
deleted file mode 100644
index 3101e51..0000000
--- a/home/shell/fish/functions/nix-rebuild-hm.fish
+++ /dev/null
@@ -1,4 +0,0 @@
-function nix-rebuild-hm --description "rebuild home manager"
-    cd ~/workspace/world
-    home-manager switch --flake .
-end
diff --git a/home/shell/fish/functions/nix-rebuild-host.fish b/home/shell/fish/functions/nix-rebuild-host.fish
deleted file mode 100644
index 02c0050..0000000
--- a/home/shell/fish/functions/nix-rebuild-host.fish
+++ /dev/null
@@ -1,4 +0,0 @@
-function nix-rebuild-host --description "rebuild the current host"
-    cd ~/workspace/world
-    sudo nixos-rebuild switch --flake .
-end
diff --git a/home/shell/fish/interactive.fish b/home/shell/fish/interactive.fish
deleted file mode 100644
index 4adcba8..0000000
--- a/home/shell/fish/interactive.fish
+++ /dev/null
@@ -1,8 +0,0 @@
-# Tmux on terminal start, unless we're in a SSH connection
-if status is-interactive
-    if test -z "$SSH_CONNECTION"
-        if not tmux has-session 2>/dev/null; or test -z "$TMUX"
-            exec tmux new-session -A -s 0
-        end
-    end
-end
diff --git a/home/shell/fish/login.fish b/home/shell/fish/login.fish
deleted file mode 100644
index 8f29553..0000000
--- a/home/shell/fish/login.fish
+++ /dev/null
@@ -1,10 +0,0 @@
-# disable greeting
-set -U fish_greeting ''
-
-# set up ssh-agent
-find-ssh-agent
-
-# start sway
-if test -z "$DISPLAY"; and test (tty) = "/dev/tty1"
-    exec sway
-end
diff --git a/home/shell/zsh/completion-style.zsh b/home/shell/zsh/completion-style.zsh
deleted file mode 100644
index 79a4e68..0000000
--- a/home/shell/zsh/completion-style.zsh
+++ /dev/null
@@ -1,42 +0,0 @@
-# 'ctrl-x r' will complete the 12 last modified (mtime) files/directories
-zle -C newest-files menu-complete _generic
-# Use "*newest-files" so that it matches both "newest-files" and
-# "load-completion-and-newest-files".
-zstyle ':completion:*newest-files:*' completer _files
-zstyle ':completion:*newest-files:*' file-patterns '*(omN[1,12])'
-zstyle ':completion:*newest-files:*' menu select yes
-zstyle ':completion:*newest-files:*' sort false
-zstyle ':completion:*newest-files:*' matcher-list 'b:=*' # important
-
-# colors for zsh file name completion
-zmodload zsh/complist
-zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
-
-# Show a prompt on selection
-zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
-
-# Use arrow keys in completion list
-zstyle ':completion:*' menu select
-
-# Group results by category
-zstyle ':completion:*' group-name ''
-
-# Keep directories and files separated
-zstyle ':completion:*' list-dirs-first true
-
-# match uppercase from lowercase
-zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
-
-# Filename suffixes to ignore during completion (except after rm command)
-zstyle ':completion:*:*:(^rm):*:*files' ignored-patterns '*?.old'
-
-# command for process lists, the local web server details and host completion
-# on processes completion complete all user processes
-zstyle ':completion:*:processes' command 'ps -au$USER'
-
-# Completion formatting and messages
-zstyle ':completion:*' verbose yes
-zstyle ':completion:*:descriptions' format '%B%d%b'
-zstyle ':completion:*:messages' format '%d'
-zstyle ':completion:*:warnings' format 'No matches for: %d'
-zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b'
diff --git a/home/shell/zsh/default.nix b/home/shell/zsh/default.nix
deleted file mode 100644
index 3734fc3..0000000
--- a/home/shell/zsh/default.nix
+++ /dev/null
@@ -1,48 +0,0 @@
-{ config, pkgs, lib, ... }:
-let
-  cfg = config.my.home.shell;
-  aliases = config.my.home.shell.aliases;
-in
-{
-  config = lib.mkIf (cfg.name == "zsh") {
-    home.packages = with pkgs; [ zsh-completions ];
-
-    programs.zsh = {
-      enable = true;
-      dotDir = ".config/zsh";
-
-      enableCompletion = true;
-      enableAutosuggestions = true;
-
-      history = {
-        size = 500000;
-        save = 500000;
-        extended = false;
-        ignoreSpace = true;
-        ignoreDups = true;
-        share = false;
-        # see
-        # https://github.com/nix-community/home-manager/blob/32a7da69dc53c9eb5ad0675eb7fdc58f7fe35272/modules/programs/zsh.nix#L537
-        path = ".local/share/zsh/zsh_history";
-      };
-
-      localVariables = {
-        # Print timing statistics for everything which takes longer than 5 seconds of
-        # user + system time.
-        REPORTTIME = 5;
-      };
-
-      shellAliases = aliases;
-
-      defaultKeymap = "emacs";
-
-      initExtra = lib.concatMapStrings builtins.readFile [
-        ./completion-style.zsh
-        ./options.zsh
-        ./prompt.zsh
-        ./tmux.zsh
-        ./new-go-project.zsh
-      ];
-    };
-  };
-}
diff --git a/home/shell/zsh/new-go-project.zsh b/home/shell/zsh/new-go-project.zsh
deleted file mode 100644
index 0b96a34..0000000
--- a/home/shell/zsh/new-go-project.zsh
+++ /dev/null
@@ -1,19 +0,0 @@
-new-go-project() {
-  local project_name=$1
-
-  echo "> creating ${project_name}"
-  cd ~/workspace/
-  mkdir $project_name
-  cd $project_name
-
-  echo "> initializing the git repository"
-  git init .
-
-  echo "> setting the default template for go projects"
-  nix flake init -t ~/workspace/world/templates#go
-  direnv allow
-
-  echo "> creating initial commit, touch your yubikey"
-  git add .
-  git commit -m 'initial commit'
-}
diff --git a/home/shell/zsh/options.zsh b/home/shell/zsh/options.zsh
deleted file mode 100644
index 6d39bc1..0000000
--- a/home/shell/zsh/options.zsh
+++ /dev/null
@@ -1,27 +0,0 @@
-# Show an error when a globbing expansion doesn't find any match
-setopt nomatch
-
-# List on ambiguous completion and Insert first match immediately
-setopt autolist menucomplete
-
-# Use pushd when cd-ing around
-setopt autopushd pushdminus pushdsilent
-
-# Use single quotes in string without the weird escape tricks
-setopt rcquotes
-
-# Single word commands can resume an existing job
-setopt autoresume
-
-# Append commands to history as they are exectuted
-setopt inc_append_history_time
-
-# Remove useless whitespace from commands
-setopt hist_reduce_blanks
-
-# Those options aren't wanted
-unsetopt beep extendedglob notify
-
-# word select works like in bash
-autoload -U select-word-style
-select-word-style bash
diff --git a/home/shell/zsh/prompt.zsh b/home/shell/zsh/prompt.zsh
deleted file mode 100644
index 8a3efa9..0000000
--- a/home/shell/zsh/prompt.zsh
+++ /dev/null
@@ -1,17 +0,0 @@
-setopt prompt_subst
-
-autoload -Uz vcs_info
-
-# display the name of the branch
-zstyle ':vcs_info:git*' formats " [%b]"
-zstyle ':vcs_info:*' enable git
-
-precmd () { vcs_info }
-PROMPT='%m%f:%F{green}%~%f%F{yellow}$vcs_info_msg_0_ %F{reset}'
-
-# For tramp (emacs).
-if [ "$TERM" = "dumb" ]; then
-  unset PROMPT
-  PS1='$ '
-  unsetopt zle
-fi
diff --git a/home/shell/zsh/tmux.zsh b/home/shell/zsh/tmux.zsh
deleted file mode 100644
index 97944f5..0000000
--- a/home/shell/zsh/tmux.zsh
+++ /dev/null
@@ -1,9 +0,0 @@
-# If we're not in an ssh connection, and tmux is installed, and we're
-# not already in a tmux session, attach to the session named
-# 'default', and if the session does not exist, start one named
-# 'default'
-if [ -z "$SSH_CONNECTION" ]; then
-  if command -v tmux &> /dev/null && [ -z "$TMUX" ]; then
-    tmux attach -t default || tmux new -s default
-  fi
-fi