aboutsummaryrefslogtreecommitdiff
path: root/config/zsh
diff options
context:
space:
mode:
Diffstat (limited to 'config/zsh')
-rw-r--r--config/zsh/aliases.zsh3
-rw-r--r--config/zsh/aliases/dev.zsh83
-rw-r--r--config/zsh/aliases/system.zsh16
-rw-r--r--config/zsh/plugins/fzf-cd.zsh16
4 files changed, 69 insertions, 49 deletions
diff --git a/config/zsh/aliases.zsh b/config/zsh/aliases.zsh
index d9a5ef6..32586e0 100644
--- a/config/zsh/aliases.zsh
+++ b/config/zsh/aliases.zsh
@@ -9,6 +9,9 @@ alias e="sensible-editor";
alias v="nvim";
alias o='open $(fzf)';
+alias j='just';
+alias jl='just -l';
+
# Load work aliases
# source "$HOME/.work-config/zshconf/aliases.zsh";
diff --git a/config/zsh/aliases/dev.zsh b/config/zsh/aliases/dev.zsh
index 4283a2d..cd2de8c 100644
--- a/config/zsh/aliases/dev.zsh
+++ b/config/zsh/aliases/dev.zsh
@@ -6,6 +6,13 @@ alias aws="docker run --rm -it amazon/aws-cli"
# nix shell with zsh
nix-zsh() { nix-shell --run "WITH_NIX_PREFIX='${NX_PREFIX:-':'}' zsh" "$@"; }
+# Gitignore locally per-project
+# Eg - gitignore-locally flake.nix flake.lock
+gitignore-locally() {
+ git add --intent-to-add "$@";
+ git update-index --assume-unchanged "$@";
+}
+
# :: Filename Pattern Replacetext
far() {
local file_r="$1"; shift;
@@ -15,8 +22,8 @@ far() {
}
# :: FileType Filename
-codi() {
- local syntax="${1:-python}"
+calc() {
+ local syntax="${1:-javascript}"
shift
nvim -c \
"let g:startify_disable_at_vimenter = 1 |\
@@ -27,18 +34,23 @@ codi() {
Codi $syntax" "$@"
}
+get_node_script_runner() {
+ if [[ -f ./yarn.json ]]; then echo "yarn";
+ elif [[ -f ./pnpm-lock.yaml ]]; then echo "pnpm";
+ else echo "npm run"; fi;
+}
# Npm run key binding
+# local commands=$(node -e 'const pkg = require("./package.json"); Object.entries(pkg.scripts || {}).map(([key, value]) => console.log(`${key}\t\t\t"${value}"`))');
+# local result=$(echo -e "$commands" | fzf | cut -f1);
p__run_npm_script() {
[[ ! -f "package.json" ]] && return 1;
- local commands=$(node -e 'const pkg = require("./package.json"); Object.entries(pkg.scripts || {}).map(([key, value]) => console.log(`${key}\t\t "${value}"`))');
- # cat package.json | jq -r '.scripts | to_entries | map([.key, .value] | join("\t\t\t")) | .[]' | fzf | cut -f1
-
- local result=$(echo -e "$commands" | fzf | cut -f1);
-
+ local result=$(cat package.json | jq -r '.scripts | to_entries | map([.key, .value] | join("\t\t\t")) | .[]' | fzf | cut -f1);
[[ -z "$result" ]] && return 1;
- yarn "$result";
+
+ print -Rz - "$(get_node_script_runner) $result ";
+ zle send-break
}
zle -N p__run_npm_script;
@@ -47,46 +59,25 @@ bindkey '^B' p__run_npm_script;
# Load shell
-p__load_nix_shell_file() {
- if [[ -f "./default.nix" ]]; then
- echo "";
- echo "ERR: default.nix already exists in directory";
- zle send-break;
- return 1;
- fi;
+# p__load_nix_shell_file() {
+# if [[ -f "./default.nix" ]]; then
+# echo "";
+# echo "ERR: default.nix already exists in directory";
+# zle send-break;
+# return 1;
+# fi;
+#
+# local shells=$(ls ~/nixos/shell);
+# local selected=$(echo -e "$shells" | fzf);
+# [[ -z "$selected" ]] && return 1;
+# cp ~/nixos/shell/$selected ./default.nix;
+# zle send-break
+# }
+#
+# zle -N p__load_nix_shell_file;
+# bindkey '^N' p__load_nix_shell_file;
- local shells=$(ls ~/nixos/shell);
- local selected=$(echo -e "$shells" | fzf);
- [[ -z "$selected" ]] && return 1;
- cp ~/nixos/shell/$selected ./default.nix;
- zle send-break
-}
-
-zle -N p__load_nix_shell_file;
-bindkey '^N' p__load_nix_shell_file;
-
-
-
-# Enter shell
-p__enter_nixshell() {
- if [[ -f "./default.nix" ]] || [[ -f "./shell.nix" ]]; then
- shell="nix-zsh"
- if [[ -f "./shell.nix" ]]; then
- shell="nix-zsh ./shell.nix"
- fi
- $shell
- zle send-break
- return 0;
- else
- echo "";
- echo "ERR: No default.nix or shell.nix in directory";
- zle send-break;
- return 1;
- fi;
-}
-zle -N p__enter_nixshell;
-bindkey '^X' p__enter_nixshell;
fix-interpreter() {
nix-shell -p patchelf --run "patchelf --set-interpreter \$(patchelf --print-interpreter \$(which mkdir)) $@"
diff --git a/config/zsh/aliases/system.zsh b/config/zsh/aliases/system.zsh
index 4554289..031bb1b 100644
--- a/config/zsh/aliases/system.zsh
+++ b/config/zsh/aliases/system.zsh
@@ -21,3 +21,19 @@ nix-rollback() {
#sv_enable() { [[ -f "/etc/runit/sv/$1" ]] && sudo ln -s /etc/runit/sv/$1 /run/runit/service; }
#sv_disable() { sudo unlink /run/runit/service/$1; }
+setup_webcam_day() {
+ v4l2-ctl -d /dev/video2 --set-ctrl exposure_absolute=300
+ v4l2-ctl -d /dev/video2 --set-ctrl gamma=180
+ v4l2-ctl -d /dev/video2 --set-ctrl saturation=17
+ v4l2-ctl -d /dev/video2 --set-ctrl contrast=12
+ v4l2-ctl -d /dev/video2 --set-ctrl brightness=1
+}
+
+setup_webcam_night() {
+ v4l2-ctl -d /dev/video2 --set-ctrl exposure_absolute=400
+ v4l2-ctl -d /dev/video2 --set-ctrl gamma=230
+ v4l2-ctl -d /dev/video2 --set-ctrl saturation=16
+ v4l2-ctl -d /dev/video2 --set-ctrl contrast=11
+ v4l2-ctl -d /dev/video2 --set-ctrl brightness=1
+}
+
diff --git a/config/zsh/plugins/fzf-cd.zsh b/config/zsh/plugins/fzf-cd.zsh
index e4b4337..f1897c5 100644
--- a/config/zsh/plugins/fzf-cd.zsh
+++ b/config/zsh/plugins/fzf-cd.zsh
@@ -1,12 +1,22 @@
+
+fzf-change-dir-cwd() { # fzf + cd in cwd
+ selected=$(find . -maxdepth 1 -type d | fzf);
+ if [ ! -z "$selected" ] && [ "$selected" != "$(pwd)" ]; then
+ cd $selected;
+ fi
+ zle send-break
+}
+
+zle -N fzf-change-dir-cwd;
+bindkey '^O' fzf-change-dir-cwd;
+
fzf-change-dir() {
local result=$(find -type d | fzf);
-
if ! [[ -z "$result" ]]; then
cd "$result"
fi
-
zle send-break
}
zle -N fzf-change-dir;
-bindkey '^P' fzf-change-dir;
+bindkey '^F' fzf-change-dir;