-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: custom scripts with zsh completion
- Loading branch information
Showing
6 changed files
with
60 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ inputs, config, lib, pkgs, ... }: | ||
|
||
with lib; | ||
let | ||
cfg = config.modules.scripts; | ||
mylib = import ../../lib { inherit inputs lib pkgs; }; | ||
in | ||
{ | ||
options.modules.scripts = { | ||
enable = mylib.mkBoolOpt false; | ||
}; | ||
|
||
# TODO: Package scripts correctly | ||
config = mkIf cfg.enable { | ||
home.file."bin" = { | ||
source = ../scripts; | ||
recursive = true; | ||
}; | ||
|
||
# Add $HOME/bin to $PATH | ||
modules.shell.zsh.envInit = '' | ||
export PATH="$HOME/bin:$PATH" | ||
''; | ||
|
||
# Add $HOME/bin/completions to $fpath | ||
modules.shell.zsh.rcInit = '' | ||
fpath+=($HOME/bin/completions) | ||
''; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ inputs, config, options, lib, pkgs, ... }: | ||
{ inputs, config, lib, pkgs, ... }: | ||
|
||
with lib; | ||
let | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
# Interactive cd to repo in ~/Code | ||
|
||
PROJECTS_DIR=${PROJECTS_DIR:-~/Code} | ||
|
||
# Test | ||
project_dirs() { | ||
find "$PROJECTS_DIR" -maxdepth 1 -type d -not -path "$PROJECTS_DIR" | sort | xargs --max-lines=1 basename | ||
} | ||
|
||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then | ||
query=${1:-''} | ||
new_dir=$(project_dirs | fzf-tmux --query "$1" --preview "if [ -f \"${PROJECTS_DIR}\"/{}/README.md ]; then glow \"${PROJECTS_DIR}\"/{}/README.md --style=dark; else ls \"${PROJECTS_DIR}\"/{}; fi") | ||
if [[ -n $new_dir ]]; then | ||
cd $PROJECTS_DIR/$new_dir | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#compdef ccd | ||
|
||
|
||
PROJECTS_DIR=${PROJECTS_DIR:-~/Code} | ||
|
||
local -a subdirs | ||
subdirs=($(find "$PROJECTS_DIR" -maxdepth 1 -type d -not -path "$PROJECTS_DIR" -exec basename {} \;)) | ||
_describe -t directories "project directory" subdirs -S/ | ||
|
||
return 0 |