about summary refs log tree commit diff
path: root/home/shell
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2023-03-11 14:33:26 -0800
committerFranck Cuny <franck@fcuny.net>2023-03-11 14:33:26 -0800
commitdea91567f215c0245517f9b87d28130a291a19a6 (patch)
tree0a7457b90f224467ff9994fbc1435a9524528878 /home/shell
parentsecrets: move aptos' gcloud secrets to homeage (diff)
downloadworld-dea91567f215c0245517f9b87d28130a291a19a6.tar.gz
home/shell: switch the default shell back to zsh
I keep running into issues when using fish: I'm not familiar with the
syntax and I don't use it enough that it sticks. I also need to google
stuff regularly to figure out how things are supposed to work. This is
annoying enough that the supposed benefits of fish are not worth it for
me.
Diffstat (limited to '')
-rw-r--r--home/shell/aliases.nix2
-rw-r--r--home/shell/zsh/completion-style.zsh18
-rw-r--r--home/shell/zsh/default.nix1
-rw-r--r--home/shell/zsh/new-go-project.zsh19
-rw-r--r--home/shell/zsh/prompt.zsh9
-rw-r--r--home/shell/zsh/ssh-agent.zsh3
6 files changed, 46 insertions, 6 deletions
diff --git a/home/shell/aliases.nix b/home/shell/aliases.nix
index b3190dc..1759b3c 100644
--- a/home/shell/aliases.nix
+++ b/home/shell/aliases.nix
@@ -2,4 +2,6 @@
   ll = "ls -l --color=auto";
   lt = "ls -ltrh --color=auto";
   pkgsearch = "nix search nixpkgs";
+  hms = "home-manager switch --flake .";
+  nr = "sudo nixos-rebuild switch --flake .";
 }
diff --git a/home/shell/zsh/completion-style.zsh b/home/shell/zsh/completion-style.zsh
index 32bd6f4..79a4e68 100644
--- a/home/shell/zsh/completion-style.zsh
+++ b/home/shell/zsh/completion-style.zsh
@@ -1,5 +1,16 @@
-# Style the completion a bit
-zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
+# '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'
@@ -13,9 +24,6 @@ zstyle ':completion:*' group-name ''
 # Keep directories and files separated
 zstyle ':completion:*' list-dirs-first true
 
-# Add colors to processes for kill completion
-zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
-
 # match uppercase from lowercase
 zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
 
diff --git a/home/shell/zsh/default.nix b/home/shell/zsh/default.nix
index ffc6c41..67cc370 100644
--- a/home/shell/zsh/default.nix
+++ b/home/shell/zsh/default.nix
@@ -46,6 +46,7 @@ in
         ./options.zsh
         ./prompt.zsh
         ./tmux.zsh
+        ./ssh-agent.zsh
       ];
     };
   };
diff --git a/home/shell/zsh/new-go-project.zsh b/home/shell/zsh/new-go-project.zsh
new file mode 100644
index 0000000..0b96a34
--- /dev/null
+++ b/home/shell/zsh/new-go-project.zsh
@@ -0,0 +1,19 @@
+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/prompt.zsh b/home/shell/zsh/prompt.zsh
index 291f436..8473f72 100644
--- a/home/shell/zsh/prompt.zsh
+++ b/home/shell/zsh/prompt.zsh
@@ -1,6 +1,13 @@
 setopt prompt_subst
 
-PROMPT='%K{cyan}%F{black}%m%k%f %~ %% '
+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="%K{cyan}%F{black}%n@%m%k%F{yellow}%~%f %F{green}${vcs_info_msg_0_}%f%% "
 
 # For tramp (emacs).
 if [ "$TERM" = "dumb" ]; then
diff --git a/home/shell/zsh/ssh-agent.zsh b/home/shell/zsh/ssh-agent.zsh
new file mode 100644
index 0000000..1e5d81c
--- /dev/null
+++ b/home/shell/zsh/ssh-agent.zsh
@@ -0,0 +1,3 @@
+if [ $(ps ax | grep "[s]sh-agent" | wc -l) -eq 0 ] ; then
+  eval $(ssh-agent -s -a ${XDG_RUNTIME_DIR}/ssh-agent.sock) > /dev/null
+fi