From dea91567f215c0245517f9b87d28130a291a19a6 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Sat, 11 Mar 2023 14:33:26 -0800 Subject: 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. --- home/shell/aliases.nix | 2 ++ home/shell/zsh/completion-style.zsh | 18 +++++++++++++----- home/shell/zsh/default.nix | 1 + home/shell/zsh/new-go-project.zsh | 19 +++++++++++++++++++ home/shell/zsh/prompt.zsh | 9 ++++++++- home/shell/zsh/ssh-agent.zsh | 3 +++ 6 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 home/shell/zsh/new-go-project.zsh create mode 100644 home/shell/zsh/ssh-agent.zsh (limited to 'home/shell') 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 -- cgit 1.4.1