This commit is contained in:
commit
95a533c876
451 changed files with 18255 additions and 0 deletions
77
modules/home/common/cdf.sh
Normal file
77
modules/home/common/cdf.sh
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
# change directory with fzf
|
||||
# Usage: cdf [optional_relative_path]
|
||||
# - If no argument, searches from $HOME.
|
||||
# - If a relative path (e.g., "projects/my_app") is provided, searches only within that path relative to $HOME.
|
||||
# - If an absolute path (e.g., "/mnt/data") is provided, searches only within that path.
|
||||
function cdf() {
|
||||
local exclude_names=(
|
||||
".cache"
|
||||
".cargo"
|
||||
".git"
|
||||
".npm"
|
||||
".rustup"
|
||||
".venv"
|
||||
"Library"
|
||||
"__pycache__"
|
||||
"build"
|
||||
"cache"
|
||||
"dist"
|
||||
"neorv32"
|
||||
"nixpkgs"
|
||||
"node_modules"
|
||||
"octave"
|
||||
"snap"
|
||||
"target"
|
||||
"venv"
|
||||
)
|
||||
|
||||
local dir="$HOME"
|
||||
|
||||
if [[ -n "$1" ]]; then
|
||||
if [[ "$1" == /* ]]; then
|
||||
dir="$1"
|
||||
else
|
||||
dir="$HOME/$1"
|
||||
fi
|
||||
|
||||
if [[ ! -d "$dir" ]]; then
|
||||
echo "Error: '$dir' does not exist or is not a directory."
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
local find_args=("$dir")
|
||||
find_args+=(-path "$dir/.*" -prune -o)
|
||||
|
||||
local prune_exprs=()
|
||||
local has_prunes=false
|
||||
for name in "${exclude_names[@]}"; do
|
||||
if $has_prunes; then
|
||||
prune_exprs+=(-o)
|
||||
fi
|
||||
prune_exprs+=(-name "$name")
|
||||
has_prunes=true
|
||||
done
|
||||
|
||||
if $has_prunes; then
|
||||
find_args+=(\( "${prune_exprs[@]}" \) -prune -o)
|
||||
fi
|
||||
|
||||
find_args+=(-type d -print)
|
||||
|
||||
local fzf_args=(
|
||||
"-i"
|
||||
"--height=40%"
|
||||
"--reverse"
|
||||
"--prompt=Select directory: "
|
||||
"--preview=tree -C {} | head -50"
|
||||
"--preview-window=right:50%:wrap"
|
||||
)
|
||||
local selected=$(find "${find_args[@]}" 2>/dev/null | fzf "${fzf_args[@]}")
|
||||
|
||||
if [[ -n "$selected" ]]; then
|
||||
cd "$selected" || echo "Failed to cd into '$selected'"
|
||||
pwd
|
||||
ls -lAh
|
||||
fi
|
||||
}
|
||||
30
modules/home/common/default.nix
Normal file
30
modules/home/common/default.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib) mkDefault;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./packages.nix
|
||||
./shellAliases.nix
|
||||
./zsh.nix
|
||||
|
||||
../../shared/common
|
||||
];
|
||||
|
||||
programs.home-manager.enable = true;
|
||||
|
||||
home.homeDirectory = mkDefault "/home/${config.home.username}";
|
||||
|
||||
# Nicely reload system units when changing configs
|
||||
systemd.user.startServices = "sd-switch";
|
||||
|
||||
# JSON formatted list of Home Manager options
|
||||
manual.json.enable = true;
|
||||
|
||||
news.display = "silent";
|
||||
}
|
||||
11
modules/home/common/packages.nix
Normal file
11
modules/home/common/packages.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
hydra-check
|
||||
nix-init
|
||||
tldr
|
||||
|
||||
(callPackage ../../../apps/rebuild { })
|
||||
];
|
||||
}
|
||||
33
modules/home/common/shellAliases.nix
Normal file
33
modules/home/common/shellAliases.nix
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
home.shellAliases = {
|
||||
l = "ls -lh";
|
||||
ll = "ls -lAh";
|
||||
ports = "ss -tulpn";
|
||||
publicip = "curl ifconfig.me/all";
|
||||
sudo = "sudo "; # make aliases work with `sudo`
|
||||
|
||||
# systemd
|
||||
userctl = "systemctl --user";
|
||||
enable = "systemctl --user enable";
|
||||
disable = "systemctl --user disable";
|
||||
start = "systemctl --user start";
|
||||
stop = "systemctl --user stop";
|
||||
journal = "journalctl --user";
|
||||
|
||||
# git
|
||||
ga = "git add";
|
||||
gb = "git branch";
|
||||
gc = "git commit";
|
||||
gcl = "git clone";
|
||||
gco = "git checkout";
|
||||
gcp = "git cherry-pick -x";
|
||||
gd = "git diff";
|
||||
gf = "git fetch --all";
|
||||
gl = "git log";
|
||||
gm = "git merge";
|
||||
gp = "git push";
|
||||
gpl = "git pull";
|
||||
gr = "git remote";
|
||||
gs = "git status";
|
||||
};
|
||||
}
|
||||
17
modules/home/common/zsh.nix
Normal file
17
modules/home/common/zsh.nix
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkDefault;
|
||||
in
|
||||
{
|
||||
programs.zsh = {
|
||||
enable = mkDefault true;
|
||||
dotDir = "${config.xdg.configHome}/zsh";
|
||||
defaultKeymap = mkDefault "emacs";
|
||||
initContent = ''
|
||||
PROMPT='%F{green}%n%f@%F{blue}%m%f %B%1~%b > '
|
||||
RPROMPT='[%F{yellow}%?%f]'
|
||||
''
|
||||
+ builtins.readFile ./cdf.sh;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue