aboutsummaryrefslogtreecommitdiff
path: root/config/zsh/aliases/dev.zsh
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2021-04-11 14:05:03 +0530
committerAkshay Nair <phenax5@gmail.com>2021-04-11 14:05:03 +0530
commit5d40bd31a395507fccafcc6ef9526b4649993c68 (patch)
tree16aaf7f76503d7d22d3fd2f64fdda75d905f00d1 /config/zsh/aliases/dev.zsh
parentf8b7b030d293c17232753103564eba7e2f417a24 (diff)
downloadnixos-config-5d40bd31a395507fccafcc6ef9526b4649993c68.tar.gz
nixos-config-5d40bd31a395507fccafcc6ef9526b4649993c68.zip
Adds key binding for loading shell in cwd
Diffstat (limited to 'config/zsh/aliases/dev.zsh')
-rw-r--r--config/zsh/aliases/dev.zsh37
1 files changed, 37 insertions, 0 deletions
diff --git a/config/zsh/aliases/dev.zsh b/config/zsh/aliases/dev.zsh
index 1e6587f..05faae8 100644
--- a/config/zsh/aliases/dev.zsh
+++ b/config/zsh/aliases/dev.zsh
@@ -34,3 +34,40 @@ codi() {
Codi $syntax" "$@"
}
+
+# Npm run key binding
+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}"`))');
+
+ local result=$(echo -e "$commands" | fzf | cut -f1);
+
+ [[ -z "$result" ]] && return 1;
+ yarn "$result";
+}
+
+zle -N p__run_npm_script;
+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;
+
+ 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;
+