Refactor home modules and update configs
- Remove unused `pkgs` import from hardware and adjust user stateVersion to 25.11 with updated wheel comment. - Split Bash aliases and functions into separate modules and rename `bash.nix` to `bash/default.nix` with imports. - Delete old Bash alias/function files and consolidate them under the new structure. - Simplify `bat.nix` by removing commented style lines. - Increase Cava `frame_rate` from 60 to 144 and clean up legacy color settings. - Refactor Chromium configuration: separate extensions into `extensions.nix` and use a minimal default module. - Replace large Kitty config with minimal enable/module and import `extra-config.nix` and `settings.nix`. - Overhaul Librewolf setup: extract profiles, extensions, search, and settings into dedicated files. - Update home `default.nix` imports to reflect new module paths and remove obsolete references. - Modularize SwayNC by moving settings and style to separate files. - Add explicit Vesktop package definition. - Remove old VSCode module; introduce VSCodium with profile-based extensions, keybindings, and user settings. - Reorganize XDG portal and desktop entries into modular files. - Rebuild Zed configuration: split user settings, language models, languages, LSP, extensions, and extra packages into distinct files.
This commit is contained in:
128
modules/home/bash/aliases.nix
Normal file
128
modules/home/bash/aliases.nix
Normal file
@@ -0,0 +1,128 @@
|
||||
{
|
||||
username,
|
||||
host,
|
||||
...
|
||||
}: {
|
||||
programs.bash.shellAliases = {
|
||||
# GarandOS aliases
|
||||
pullos = "git -C /home/${username}/garandos pull";
|
||||
upd = "nh os switch --hostname ${host}";
|
||||
upg = "nh os switch --hostname ${host} --update";
|
||||
upf = "sudo nix flake update";
|
||||
upd-bt = "nh os boot --hostname ${host}";
|
||||
upd-ts = "nh os test --hostname ${host}";
|
||||
upd-bd = "nh os build --hostname ${host}";
|
||||
ncg = "nh clean all";
|
||||
|
||||
# Development aliases
|
||||
srvenv = "source .venv/bin/activate";
|
||||
"..srvenv" = "source ../.venv/bin/activate";
|
||||
pm = "uv run manage.py";
|
||||
f8 = "uv run flake8 .";
|
||||
bbr = "bun --bun run";
|
||||
mkgidf = "git add . --intent-to-add . && git diff > git-diff.txt";
|
||||
zed = "MANGOHUD=0 /home/${username}/.local/bin/zed";
|
||||
|
||||
# Development aliases for nix flake
|
||||
nd = "nix develop";
|
||||
nb = "nix build";
|
||||
nr = "nix run";
|
||||
nbr = "nix build && nix run";
|
||||
nbd = "nix build .#develop";
|
||||
nrd = "nix run .#develop";
|
||||
nbrd = "nix build .#develop && nix run .#develop";
|
||||
|
||||
# System aliases
|
||||
# flush-codium = "sudo killall codium && sudo rm -rf ~/.config/VSCodium/Cache && sudo rm -rf ~/.config/VSCodium/CachedData";
|
||||
kys = "shutdown now";
|
||||
ookla = "speedtest";
|
||||
hypr-cli = "hyprctl clients";
|
||||
|
||||
# Navigation aliases
|
||||
"~" = "cd ~";
|
||||
".." = "cd ..";
|
||||
"..." = "cd ../..";
|
||||
"...." = "cd ../../..";
|
||||
"....." = "cd ../../../..";
|
||||
|
||||
# Modifies commands
|
||||
cat = "bat";
|
||||
cp = "cp -i";
|
||||
mv = "mv -i";
|
||||
rm = "trash -v";
|
||||
mkdir = "mkdir -p";
|
||||
ps = "ps auxf";
|
||||
ping = "ping -c 10";
|
||||
less = "less -R";
|
||||
cls = "clear";
|
||||
multitail = "multitail --no-repeat -c";
|
||||
freshclam = "sudo freshclam";
|
||||
|
||||
# Alias"s for multiple directory listing commands
|
||||
la = "eza -alh --icons"; # show hidden files
|
||||
ls = "eza -aF --icons --color=always"; # add colors and file type extensions
|
||||
lx = "eza -lh --icons --sort=extension"; # sort by extension
|
||||
lk = "eza -lh --icons --sort=size --reverse"; # sort by size
|
||||
lc = "eza -lh --icons --sort=changed"; # sort by change time
|
||||
lu = "eza -lh --icons --sort=accessed"; # sort by access time
|
||||
lr = "eza -lh --icons --recurse"; # recursive ls
|
||||
lt = "eza -lh --icons --sort=modified"; # sort by date
|
||||
lm = "eza -alh --icons | more"; # pipe through "more"
|
||||
lw = "eza -xh --icons"; # wide listing format
|
||||
ll = "eza -lh --icons"; # long listing format
|
||||
labc = "eza -lah --icons --sort=name"; # alphabetical sort
|
||||
lf = "eza -lh --icons | grep -v '^d'"; # files only (przybliżenie)
|
||||
ldir = "eza -lh --icons --only-dirs"; # directories only
|
||||
lla = "eza -alh --icons"; # List and Hidden Files
|
||||
las = "eza -a --icons"; # Hidden Files
|
||||
lls = "eza -lh --icons"; # List
|
||||
|
||||
# chmod commands
|
||||
mx = "chmod a+x";
|
||||
"000" = "chmod -R 000";
|
||||
"644" = "chmod -R 644";
|
||||
"666" = "chmod -R 666";
|
||||
"755" = "chmod -R 755";
|
||||
"777" = "chmod -R 777";
|
||||
|
||||
# Search command line history
|
||||
h = "history | grep ";
|
||||
|
||||
# Search running processes
|
||||
p = "ps aux | grep ";
|
||||
topcpu = "/bin/ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10";
|
||||
|
||||
# Search files in the current folder
|
||||
f = "find . | grep ";
|
||||
|
||||
# Count all files (recursively) in the current folder
|
||||
countfiles = "for t in files links directories; do echo \`find . -type \${t:0:1} | wc -l\` \$t; done 2> /dev/null";
|
||||
|
||||
# Alias"s to show disk space and space used in a folder
|
||||
diskspace = "du -S | sort -n -r |more";
|
||||
folders = "du -h --max-depth=1";
|
||||
folderssort = "find . -maxdepth 1 -type d -print0 | xargs -0 du -sk | sort -rn";
|
||||
tree = "tree -CAhF --dirsfirst";
|
||||
treed = "tree -CAFd";
|
||||
mountedinfo = "df -hT";
|
||||
|
||||
# Show all logs in /var/log
|
||||
logs = "sudo find /var/log -type f -exec file {} \; | grep 'text' | cut -d' ' -f1 | sed -e's/:$//g' | grep -v '[0-9]$' | xargs tail -f";
|
||||
|
||||
# fix kitty ssh connection
|
||||
kssh = "kitty +kitten ssh";
|
||||
|
||||
docker-clean = "docker container prune -f ; docker image prune -f ; docker network prune -f ; docker volume prune -f";
|
||||
|
||||
# Remove a directory and all files
|
||||
rmd = "/bin/rm --recursive --force --verbose ";
|
||||
|
||||
# Fun aliases
|
||||
pasjans = "ttysolitaire -p 10 --no-background-color";
|
||||
fc = "fortune | cowsay";
|
||||
|
||||
# Network aliases
|
||||
kssh-server = "kssh garand_plg@192.168.1.156 -i ~/.ssh/hp-t640-homeserver";
|
||||
ssh-server = "ssh garand_plg@192.168.1.156 -i ~/.ssh/hp-t640-homeserver";
|
||||
};
|
||||
}
|
||||
13
modules/home/bash/default.nix
Normal file
13
modules/home/bash/default.nix
Normal file
@@ -0,0 +1,13 @@
|
||||
_: {
|
||||
programs.bash = {
|
||||
enable = true;
|
||||
enableCompletion = true;
|
||||
# initExtra = ''
|
||||
# fastfetch
|
||||
# '';
|
||||
};
|
||||
imports = [
|
||||
./aliases.nix
|
||||
./functions.nix
|
||||
];
|
||||
}
|
||||
144
modules/home/bash/functions.nix
Normal file
144
modules/home/bash/functions.nix
Normal file
@@ -0,0 +1,144 @@
|
||||
_: {
|
||||
programs.bash.bashrcExtra = ''
|
||||
# Quick directory creation and navigation
|
||||
mkcd() {
|
||||
mkdir -p "$1" && cd "$1"
|
||||
}
|
||||
|
||||
# Extract various archive formats
|
||||
extract() {
|
||||
for archive in "$@"; do
|
||||
if [ -f "$archive" ]; then
|
||||
case "$archive" in
|
||||
*.tar.bz2) tar xvjf "$archive" ;;
|
||||
*.tar.gz) tar xvzf "$archive" ;;
|
||||
*.bz2) bunzip2 "$archive" ;;
|
||||
*.rar) unrar x "$archive" ;;
|
||||
*.gz) gunzip "$archive" ;;
|
||||
*.tar) tar xvf "$archive" ;;
|
||||
*.tbz2) tar xvjf "$archive" ;;
|
||||
*.tgz) tar xvzf "$archive" ;;
|
||||
*.zip) unzip "$archive" ;;
|
||||
*.Z) uncompress "$archive" ;;
|
||||
*.7z) 7z x "$archive" ;;
|
||||
*) echo "don't know how to extract '$archive'..." ;;
|
||||
esac
|
||||
else
|
||||
echo "'$archive' is not a valid file!"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Find files quickly
|
||||
ff() {
|
||||
find . -name "*$1*" -type f
|
||||
}
|
||||
|
||||
# Find directories quickly
|
||||
fd() {
|
||||
find . -name "*$1*" -type d
|
||||
}
|
||||
|
||||
# IP address lookup
|
||||
alias whatismyip="whatsmyip"
|
||||
function whatsmyip () {
|
||||
# Internal IP Lookup.
|
||||
if command -v ip &> /dev/null; then
|
||||
echo -n "Internal IP: "
|
||||
ip addr show wlan0 | grep "inet " | awk '{print $2}' | cut -d/ -f1
|
||||
else
|
||||
echo -n "Internal IP: "
|
||||
ifconfig wlan0 | grep "inet " | awk '{print $2}'
|
||||
fi
|
||||
|
||||
# External IP Lookup
|
||||
echo -n "External IP: "
|
||||
curl -4 ifconfig.me
|
||||
}
|
||||
|
||||
# Searches for text in all files in the current folder
|
||||
ftext() {
|
||||
# -i case-insensitive
|
||||
# -I ignore binary files
|
||||
# -H causes filename to be printed
|
||||
# -r recursive search
|
||||
# -n causes line number to be printed
|
||||
# optional: -F treat search term as a literal, not a regular expression
|
||||
# optional: -l only print filenames and not the matching lines ex. grep -irl "$1" *
|
||||
grep -iIHrn --color=always "$1" . | less -r
|
||||
}
|
||||
|
||||
# Copy file with a progress bar
|
||||
cpp() {
|
||||
set -e
|
||||
strace -q -ewrite cp -- "$1" "$2" 2>&1 |
|
||||
awk '{
|
||||
count += $NF
|
||||
if (count % 10 == 0) {
|
||||
percent = count / total_size * 100
|
||||
printf "%3d%% [", percent
|
||||
for (i=0;i<=percent;i++)
|
||||
printf "="
|
||||
printf ">"
|
||||
for (i=percent;i<100;i++)
|
||||
printf " "
|
||||
printf "]\r"
|
||||
}
|
||||
}
|
||||
END { print "" }' total_size="$(stat -c '%s' "$1")" count=0
|
||||
}
|
||||
|
||||
# Copy and go to the directory
|
||||
cpg() {
|
||||
if [ -d "$2" ]; then
|
||||
cp "$1" "$2" && cd "$2"
|
||||
else
|
||||
cp "$1" "$2"
|
||||
fi
|
||||
}
|
||||
|
||||
# Move and go to the directory
|
||||
mvg() {
|
||||
if [ -d "$2" ]; then
|
||||
mv "$1" "$2" && cd "$2"
|
||||
else
|
||||
mv "$1" "$2"
|
||||
fi
|
||||
}
|
||||
|
||||
# Create and go to the directory
|
||||
mkdirg() {
|
||||
mkdir -p "$1"
|
||||
cd "$1"
|
||||
}
|
||||
|
||||
# Goes up a specified number of directories (i.e. up 4)
|
||||
up() {
|
||||
local d=""
|
||||
limit=$1
|
||||
for ((i = 1; i <= limit; i++)); do
|
||||
d=$d/..
|
||||
done
|
||||
d=$(echo $d | sed 's/^\///')
|
||||
if [ -z "$d" ]; then
|
||||
d=..
|
||||
fi
|
||||
cd $d
|
||||
}
|
||||
|
||||
# Automatically do an ls after each cd, z, or zoxide
|
||||
cd ()
|
||||
{
|
||||
if [ -n "$1" ]; then
|
||||
builtin cd "$@" && ls
|
||||
else
|
||||
builtin cd ~ && ls
|
||||
fi
|
||||
}
|
||||
|
||||
# Returns the last 2 fields of the working directory
|
||||
pwdtail() {
|
||||
pwd | awk -F/ '{nlast = NF -1;print $nlast"/"$NF}'
|
||||
}
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user