mirror of
https://github.com/zoriya/flake.git
synced 2026-08-15 18:43:42 +00:00
Enable completion from the middle of the word & cleanup zsh config
This commit is contained in:
@@ -1,9 +1,4 @@
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
{pkgs, ...}: {
|
||||
imports = [
|
||||
./zsh
|
||||
./nvim
|
||||
@@ -26,6 +21,12 @@
|
||||
signByDefault = true;
|
||||
key = "~/.ssh/id_rsa.pub";
|
||||
};
|
||||
# TODO: unstable feature not in my fork yet
|
||||
# maintenance = {
|
||||
# enable = false;
|
||||
# # TODO: figure out a way to specify all repositories in ~/projects & ~/work at run time
|
||||
# repositories = [];
|
||||
# };
|
||||
extraConfig = {
|
||||
gpg.format = "ssh";
|
||||
gpg.ssh.allowedSignersFile = "~/.ssh/allowed_signers";
|
||||
@@ -43,7 +44,6 @@
|
||||
core.hookspath = "/dev/null";
|
||||
# Break compat with older versions of git (and systems that doesn't support mtime) to have better performances
|
||||
feature.manyFiles = true;
|
||||
# TODO: enable git maintenance
|
||||
};
|
||||
|
||||
userEmail = "zoe.roux@zoriya.dev";
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# used by kubectl plugin & maybe some other oh-my-zsh plugins
|
||||
export ZSH_CACHE_DIR="$HOME/.cache/zsh";
|
||||
mkdir -p "$ZSH_CACHE_DIR/completions"
|
||||
fpath+="$ZSH_CACHE_DIR/completions"
|
||||
|
||||
# case insensitive completion
|
||||
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
|
||||
# enable completion from the middle of the word (MUST be specified just ofter the case-insensitive completion)
|
||||
zstyle ':completion:*' matcher-list '+l:|=* r:|=*'
|
||||
# use LS_COLORS for autocompletion
|
||||
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
|
||||
# allow manual selection in the completion menu
|
||||
zstyle ':completion:*:*:*:*:*' menu select
|
||||
@@ -1,84 +0,0 @@
|
||||
push() {
|
||||
if [[ -z "$1" ]]; then
|
||||
git push
|
||||
return
|
||||
fi
|
||||
git add -A && git commit -m "$*" && git push
|
||||
}
|
||||
|
||||
git-branch-clear() {
|
||||
git fetch --prune origin
|
||||
git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -D
|
||||
}
|
||||
|
||||
nixify() {
|
||||
if [ ! -e ./.envrc ]; then
|
||||
echo "use nix" > .envrc
|
||||
fi
|
||||
if [[ ! -e shell.nix ]] && [[ ! -e default.nix ]]; then
|
||||
cat > default.nix <<'EOF'
|
||||
{pkgs ? import <nixpkgs> {}}:
|
||||
pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
|
||||
];
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
direnv allow
|
||||
}
|
||||
|
||||
flakify() {
|
||||
if [ ! -e flake.nix ]; then
|
||||
nix flake new -t github:nix-community/nix-direnv .
|
||||
elif [ ! -e .envrc ]; then
|
||||
echo "use flake" > .envrc
|
||||
fi
|
||||
direnv allow
|
||||
}
|
||||
|
||||
(whence -w run-help | grep -q alias) && unalias run-help
|
||||
autoload run-help
|
||||
|
||||
# Allow customization per client.
|
||||
[[ -f ~/.config/zsh/custom.zsh ]] && source ~/.config/zsh/custom.zsh
|
||||
|
||||
dotenv() {
|
||||
DOTENV=".env"
|
||||
if [[ $1 == "-f" ]]; then
|
||||
DOTENV=$2
|
||||
shift
|
||||
shift
|
||||
fi
|
||||
|
||||
ENV=$(cat $DOTENV | sed '/^#/d' | tr '\n' ' ')
|
||||
|
||||
if [[ -z $* ]]; then
|
||||
export ${=ENV}
|
||||
else
|
||||
(export ${=ENV}; $*)
|
||||
fi
|
||||
}
|
||||
|
||||
robot_install() {
|
||||
robot=$(\where -p robot)
|
||||
if [[ $? -eq 1 ]]; then
|
||||
pyt=$(\where -p python3)
|
||||
if [[ $? -eq 1 ]]; then
|
||||
nix-shell -p python3
|
||||
fi
|
||||
|
||||
python3 -m venv /tmp/robot
|
||||
source /tmp/robot/bin/activate
|
||||
pip3 install robotframework RESTinstance
|
||||
fi
|
||||
}
|
||||
|
||||
touchp() {
|
||||
mkdir -p "$(dirname "$1")" && touch "$1"
|
||||
}
|
||||
|
||||
proxy() {
|
||||
echo "Proxying port $1 to http://proxy.sdg.moe"
|
||||
ssh -NR "5000:localhost:$1" ssh.sdg.moe
|
||||
}
|
||||
@@ -157,8 +157,6 @@
|
||||
enable = true;
|
||||
autocd = true;
|
||||
autosuggestion.enable = true;
|
||||
# already handled at system level
|
||||
enableCompletion = false;
|
||||
syntaxHighlighting.enable = true;
|
||||
dotDir = ".config/zsh";
|
||||
shellAliases = {
|
||||
@@ -193,6 +191,12 @@
|
||||
viu = "kitty +kitten icat";
|
||||
icat = "kitty +kitten icat";
|
||||
};
|
||||
shellGlobalAliases = {
|
||||
"..." = "../..";
|
||||
"...." = "../../..";
|
||||
"....." = "../../../..";
|
||||
"......" = "../../../../..";
|
||||
};
|
||||
|
||||
plugins = [
|
||||
{
|
||||
@@ -205,11 +209,6 @@
|
||||
src = pkgs.zsh-vi-mode;
|
||||
file = "share/zsh-vi-mode/zsh-vi-mode.zsh";
|
||||
}
|
||||
{
|
||||
name = "custom";
|
||||
src = ./.;
|
||||
file = "./custom.zsh";
|
||||
}
|
||||
{
|
||||
name = "sudo";
|
||||
src = pkgs.oh-my-zsh;
|
||||
@@ -241,14 +240,19 @@
|
||||
file = "share/oh-my-zsh/plugins/copyfile/copyfile.plugin.zsh";
|
||||
}
|
||||
];
|
||||
initExtra = builtins.readFile ./init.zsh;
|
||||
|
||||
initExtraFirst = ''
|
||||
# Create a new tmux session (with a random name) and attach.
|
||||
if [[ -z "$TMUX" ]]; then
|
||||
exec tmux new-session -s "$(hexdump -n 4 -v -e '/1 "%02X"' /dev/urandom)"
|
||||
fi
|
||||
'';
|
||||
initExtraBeforeCompInit = builtins.readFile ./comp.zsh;
|
||||
initExtra = builtins.readFile ./init.zsh;
|
||||
|
||||
envExtra = ''
|
||||
# disable /etc/zshrc & co (nixos one is really bad)
|
||||
setopt no_global_rcs
|
||||
'';
|
||||
|
||||
# zprof.enable = true;
|
||||
|
||||
|
||||
+84
-15
@@ -1,7 +1,3 @@
|
||||
export ZSH_CACHE_DIR="$HOME/.cache/zsh";
|
||||
mkdir -p "$ZSH_CACHE_DIR/completions"
|
||||
fpath+="$ZSH_CACHE_DIR/completions"
|
||||
|
||||
# This speeds up pasting w/ autosuggest
|
||||
# https://github.com/zsh-users/zsh-autosuggestions/issues/238
|
||||
pasteinit() {
|
||||
@@ -42,18 +38,91 @@ eval "$(nix-your-shell zsh)"
|
||||
|
||||
setopt rm_star_silent
|
||||
|
||||
# case insensitive completion
|
||||
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
|
||||
# use LS_COLORS for autocompletion
|
||||
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
|
||||
# allow manual selection in the completion menu
|
||||
zstyle ':completion:*:*:*:*:*' menu select
|
||||
|
||||
# ctrl-left/right
|
||||
bindkey "^[[1;5C" forward-word
|
||||
bindkey "^[[1;5D" backward-word
|
||||
|
||||
alias -g ...='../..'
|
||||
alias -g ....='../../..'
|
||||
alias -g .....='../../../..'
|
||||
alias -g ......='../../../../..'
|
||||
# Allow customization per client.
|
||||
[[ -f ~/.config/zsh/custom.zsh ]] && source ~/.config/zsh/custom.zsh
|
||||
|
||||
push() {
|
||||
if [[ -z "$1" ]]; then
|
||||
git push
|
||||
return
|
||||
fi
|
||||
git add -A && git commit -m "$*" && git push
|
||||
}
|
||||
|
||||
git-branch-clear() {
|
||||
git fetch --prune origin
|
||||
git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -D
|
||||
}
|
||||
|
||||
nixify() {
|
||||
if [ ! -e ./.envrc ]; then
|
||||
echo "use nix" > .envrc
|
||||
fi
|
||||
if [[ ! -e shell.nix ]]; then
|
||||
cat > shell.nix <<'EOF'
|
||||
{pkgs ? import <nixpkgs> {}}:
|
||||
pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
|
||||
];
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
direnv allow
|
||||
}
|
||||
|
||||
flakify() {
|
||||
if [ ! -e flake.nix ]; then
|
||||
nix flake new -t github:nix-community/nix-direnv .
|
||||
elif [ ! -e .envrc ]; then
|
||||
echo "use flake" > .envrc
|
||||
fi
|
||||
direnv allow
|
||||
}
|
||||
|
||||
(whence -w run-help | grep -q alias) && unalias run-help
|
||||
autoload run-help
|
||||
|
||||
dotenv() {
|
||||
DOTENV=".env"
|
||||
if [[ $1 == "-f" ]]; then
|
||||
DOTENV=$2
|
||||
shift
|
||||
shift
|
||||
fi
|
||||
|
||||
ENV=$(cat $DOTENV | sed '/^#/d' | tr '\n' ' ')
|
||||
|
||||
if [[ -z $* ]]; then
|
||||
export ${=ENV}
|
||||
else
|
||||
(export ${=ENV}; $*)
|
||||
fi
|
||||
}
|
||||
|
||||
robot_install() {
|
||||
robot=$(\where -p robot)
|
||||
if [[ $? -eq 1 ]]; then
|
||||
pyt=$(\where -p python3)
|
||||
if [[ $? -eq 1 ]]; then
|
||||
nix-shell -p python3
|
||||
fi
|
||||
|
||||
python3 -m venv /tmp/robot
|
||||
source /tmp/robot/bin/activate
|
||||
pip3 install robotframework RESTinstance
|
||||
fi
|
||||
}
|
||||
|
||||
touchp() {
|
||||
mkdir -p "$(dirname "$1")" && touch "$1"
|
||||
}
|
||||
|
||||
proxy() {
|
||||
echo "Proxying port $1 to http://proxy.sdg.moe"
|
||||
ssh -NR "5000:localhost:$1" ssh.sdg.moe
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user