aboutsummaryrefslogtreecommitdiff
path: root/config/zsh/aliases
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2023-10-15 00:51:15 +0530
committerAkshay Nair <phenax5@gmail.com>2023-10-15 00:51:15 +0530
commit32d0bd79637cdc6400798bc033c8e2149ec4c5a6 (patch)
treedf6f25cb31bb2b93a1af5104b613c96013b823b9 /config/zsh/aliases
parent4eb5f01f1f7a11527be56bd8a8afecd31d640b15 (diff)
downloadnixos-config-32d0bd79637cdc6400798bc033c8e2149ec4c5a6.tar.gz
nixos-config-32d0bd79637cdc6400798bc033c8e2149ec4c5a6.zip
config sync
Diffstat (limited to 'config/zsh/aliases')
-rw-r--r--config/zsh/aliases/dev.zsh83
-rw-r--r--config/zsh/aliases/system.zsh16
2 files changed, 53 insertions, 46 deletions
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
+}
+