From 6591f6b020e332d2cc5ed8abed363c4ff90e21cb Mon Sep 17 00:00:00 2001 From: Honney Date: Tue, 23 Jun 2026 00:23:16 +0200 Subject: [PATCH] fixed a lot of stuff --- .gitignore | 2 + conf.d/fish_frozen_key_bindings.fish | 14 - conf.d/fish_frozen_theme.fish | 37 --- conf.d/omf.fish | 6 +- config.fish | 100 +++---- configs/alias_fixing.fish | 12 +- configs/alias_useful.fish | 401 ++++++++++++++------------- configs/arch_config.fish | 80 +++--- configs/env.fish | 2 +- configs/fedora_config.fish | 8 +- configs/theme.fish | 47 +--- configs/ubuntu_config.fish | 4 +- configs/uni.fish | 14 +- fish_variables | 7 - functions/addpaths.fish | 11 +- functions/compare_sha256.fish | 15 - functions/extract.fish | 135 ++++++++- functions/findstr.fish | 12 +- functions/fish_prompt.fish_bak | 15 - functions/pack.fish | 7 +- functions/removepath.fish | 8 +- functions/search.fish | 5 +- functions/verify_file.fish | 55 ++++ install.sh | 84 ++++++ 24 files changed, 626 insertions(+), 455 deletions(-) create mode 100644 .gitignore delete mode 100644 conf.d/fish_frozen_key_bindings.fish delete mode 100644 conf.d/fish_frozen_theme.fish delete mode 100755 fish_variables delete mode 100755 functions/compare_sha256.fish delete mode 100755 functions/fish_prompt.fish_bak create mode 100644 functions/verify_file.fish create mode 100755 install.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a3633e2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +configs/colors.fish +fish_variables \ No newline at end of file diff --git a/conf.d/fish_frozen_key_bindings.fish b/conf.d/fish_frozen_key_bindings.fish deleted file mode 100644 index 495aee9..0000000 --- a/conf.d/fish_frozen_key_bindings.fish +++ /dev/null @@ -1,14 +0,0 @@ -# This file was created by fish when upgrading to version 4.3, to migrate -# the 'fish_key_bindings' variable from its old default scope (universal) -# to its new default scope (global). We recommend you delete this file -# and configure key bindings in ~/.config/fish/config.fish if needed. - -# set --global fish_key_bindings fish_default_key_bindings - -# Prior to version 4.3, fish shipped an event handler that runs -# `set --universal fish_key_bindings fish_default_key_bindings` -# whenever the fish_key_bindings variable is erased. -# This means that as long as any fish < 4.3 is still running on this system, -# we cannot complete the migration. -# As a workaround, erase the universal variable at every shell startup. -set --erase --universal fish_key_bindings diff --git a/conf.d/fish_frozen_theme.fish b/conf.d/fish_frozen_theme.fish deleted file mode 100644 index 0caf65e..0000000 --- a/conf.d/fish_frozen_theme.fish +++ /dev/null @@ -1,37 +0,0 @@ -# This file was created by fish when upgrading to version 4.3, to migrate -# theme variables from universal to global scope. -# Don't edit this file, as it will be written by the web-config tool (`fish_config`). -# To customize your theme, delete this file and see -# help interactive#syntax-highlighting -# or -# man fish-interactive | less +/^SYNTAX.HIGHLIGHTING -# for appropriate commands to add to ~/.config/fish/config.fish instead. -# See also the release notes for fish 4.3.0 (run `help relnotes`). - -set --global fish_color_autosuggestion brblack -set --global fish_color_cancel -r -set --global fish_color_command blue -set --global fish_color_comment red -set --global fish_color_cwd green -set --global fish_color_cwd_root red -set --global fish_color_end green -set --global fish_color_error brred -set --global fish_color_escape brcyan -set --global fish_color_history_current --bold -set --global fish_color_host normal -set --global fish_color_host_remote yellow -set --global fish_color_normal normal -set --global fish_color_operator brcyan -set --global fish_color_param cyan -set --global fish_color_quote yellow -set --global fish_color_redirection cyan --bold -set --global fish_color_search_match white --background=brblack -set --global fish_color_selection white --bold --background=brblack -set --global fish_color_status red -set --global fish_color_user brgreen -set --global fish_color_valid_path --underline -set --global fish_pager_color_completion normal -set --global fish_pager_color_description yellow -i -set --global fish_pager_color_prefix normal --bold --underline -set --global fish_pager_color_progress brwhite --background=cyan -set --global fish_pager_color_selected_background -r diff --git a/conf.d/omf.fish b/conf.d/omf.fish index 3e0f6d6..90aa36e 100755 --- a/conf.d/omf.fish +++ b/conf.d/omf.fish @@ -3,5 +3,7 @@ set -q XDG_DATA_HOME and set -gx OMF_PATH "$XDG_DATA_HOME/omf" or set -gx OMF_PATH "$HOME/.local/share/omf" -# Load Oh My Fish configuration. -source $OMF_PATH/init.fish +# Load Oh My Fish configuration if it exists. +if test -f $OMF_PATH/init.fish + source $OMF_PATH/init.fish +end diff --git a/config.fish b/config.fish index e25a193..1f448a7 100755 --- a/config.fish +++ b/config.fish @@ -1,65 +1,53 @@ -# source ~/.config/fish/configs/aliases.fish - -# if test -f $HOME/.config/fish/alias.fish ] -# source $HOME/.config/fish/alias.fish -# end - -set distro (cat /etc/os-release | grep ^ID= | cut -d '=' -f 2 | tr -d '"') +# Replace frozen key bindings migration (deletes fish_frozen_key_bindings.fish) +set --global fish_key_bindings fish_default_key_bindings if status is-interactive - # Commands to run in interactive sessions can go here + # Get distro ID from /etc/os-release + if test -f /etc/os-release + set -l os_id (string match -r '^ID=.*' /dev/null | string split -m1 '=' | string lower) + set -l distro $os_id[2] + else + set distro unknown + end - # Load the theme - if test -f $HOME/.config/fish/configs/theme.fish - source $HOME/.config/fish/configs/theme.fish - end + if test -f $HOME/.config/fish/configs/theme.fish + source $HOME/.config/fish/configs/theme.fish + end - # Load the aliases - if test -f $HOME/.config/fish/configs/alias_custom-script.fish - source $HOME/.config/fish/configs/alias_custom-script.fish - end - if test -f $HOME/.config/fish/configs/alias_fixing.fish - source $HOME/.config/fish/configs/alias_fixing.fish - end - if test -f $HOME/.config/fish/configs/alias_useful.fish - source $HOME/.config/fish/configs/alias_useful.fish - end - if test -f $HOME/.config/fish/configs/function_usefull.fish - source $HOME/.config/fish/configs/function_usefull.fish - end + if test -f $HOME/.config/fish/configs/alias_custom-script.fish + source $HOME/.config/fish/configs/alias_custom-script.fish + end + if test -f $HOME/.config/fish/configs/alias_fixing.fish + source $HOME/.config/fish/configs/alias_fixing.fish + end + if test -f $HOME/.config/fish/configs/alias_useful.fish + source $HOME/.config/fish/configs/alias_useful.fish + end - if test -f $HOME/.config/fish/configs/env.fish - source $HOME/.config/fish/configs/env.fish - end + if test -f $HOME/.config/fish/configs/env.fish + source $HOME/.config/fish/configs/env.fish + end - # ~/.config/fish/config.fish + switch $distro + case fedora + if test -f $HOME/.config/fish/configs/fedora_config.fish + source $HOME/.config/fish/configs/fedora_config.fish + end + case arch + if test -f $HOME/.config/fish/configs/arch_config.fish + source $HOME/.config/fish/configs/arch_config.fish + end + case ubuntu + if test -f $HOME/.config/fish/configs/ubuntu_config.fish + source $HOME/.config/fish/configs/ubuntu_config.fish + end + case '*' + if test -f $HOME/.config/fish/configs/default_config.fish + source $HOME/.config/fish/configs/default_config.fish + end + end - # Get the distribution name and version - - - switch $distro - case 'fedora' - if test -f $HOME/.config/fish/configs/fedora_config.fish - source $HOME/.config/fish/configs/fedora_config.fish - end - case 'arch' - if test -f $HOME/.config/fish/configs/arch_config.fish - source $HOME/.config/fish/configs/arch_config.fish - end - case 'ubuntu' - if test -f $HOME/.config/fish/configs/ubuntu_config.fish - source $HOME/.config/fish/configs/ubuntu_config.fish - end - case '*' - if test -f $HOME/.config/fish/configs/default_config.fish - source $HOME/.config/fish/configs/default_config.fish - end - end - if test -x /usr/bin/fastfetch - fastfetch + if test -e /usr/bin/fastfetch + fastfetch end end -# set -q GHCUP_INSTALL_BASE_PREFIX[1]; or set GHCUP_INSTALL_BASE_PREFIX $HOME ; set -gx PATH $HOME/.cabal/bin $PATH /home/honney/.ghcup/bin # ghcup-env -# set -Ux PYENV_ROOT $HOME/.pyenv -# fish_add_path $PYENV_ROOT/bin -# pyenv init - | source diff --git a/configs/alias_fixing.fish b/configs/alias_fixing.fish index 407203a..abb4885 100755 --- a/configs/alias_fixing.fish +++ b/configs/alias_fixing.fish @@ -3,17 +3,11 @@ # Fixing some Programs that do not know Kitty or Alacritty # Check if the local terminal supports color (kitty, alacritty, etc.) -if test "$TERM" = "xterm-kitty" -o "$TERM" = "alacritty" - # If we're in a non-standard terminal, force TERM=xterm-256color for SSH - alias ssh 'env TERM=xterm-256color ssh' +if test "$TERM" = "xterm-kitty"; or test "$TERM" = "alacritty" + alias ssh='env TERM=xterm-256color ssh' end -if test -f $HOME/.config/fish/alias.fish -source $HOME/.config/fish/alias.fish -end - -if test -e /usr/bin/zoxide - eval (zoxide init fish) +if command -q zoxide zoxide init fish | source alias cd='z' end diff --git a/configs/alias_useful.fish b/configs/alias_useful.fish index 92d3b26..4385b50 100755 --- a/configs/alias_useful.fish +++ b/configs/alias_useful.fish @@ -2,223 +2,259 @@ # In ~/.config/fish/configs/alias_useful.fish # -################# STUFF YOU HAVE INSTALLED ##################################### +################ COMMON ALIASES ################################################ alias remount='sudo mount -a' - alias mount_config='sudo nano /etc/fstab' - -alias force_delete='sudo rm -rf' # Delete Folder/Files with included Folder/Files - -alias own='sudo chown -R "$USER":"$USER" themes' +alias own='sudo chown -R "$USER":"$USER"' alias right='sudo chmod -R 755' - alias reload='clear && omf reload' +alias fish_config='nano $HOME/.config/fish/config.fish' +alias ip='ip -color' +alias psmem='ps auxf | sort -nr -k 4' +alias psmem10='ps auxf | sort -nr -k 4 | head -10' +alias jctl='journalctl -p 3 -xb' +alias ...='cd ../..' +alias ....='cd ../../..' +alias .....='cd ../../../..' +alias ......='cd ../../../../..' +alias dir='dir --color=auto' +alias vdir='vdir --color=auto' +alias tarnow='tar -acf' +alias untar='tar -zxvf' -alias fish_config='nano $HOME/.config/fish/config.fish' # Open the fish Config in Text editor - -alias ip 'ip -color' - -alias psmem 'ps auxf | sort -nr -k 4' -alias psmem10 'ps auxf | sort -nr -k 4 | head -10' - -alias jctl 'journalctl -p 3 -xb' - -# Common use -alias ... 'cd ../..' -alias .... 'cd ../../..' -alias ..... 'cd ../../../..' -alias ...... 'cd ../../../../..' - -alias dir 'dir --color=auto' -alias vdir 'vdir --color=auto' - -alias tarnow 'tar -acf ' -alias untar 'tar -zxvf ' - -################# HELPER ##################################################### +################ HELPERS ###################################################### function help_pdf echo "Best Tool to combine pdf: PDF Arranger" - echo "Best Tool for OCR: OCRMYPDF but you need to install the teseracts for your languages" + echo "Best Tool for OCR: OCRMYPDF but you need to install the tesseracts for your languages" echo "Best Tool to write in PDFs: XOURNAL++" end -################# STUFF YOU MAY NOT HAVE ##################################### +if test -e /usr/bin/rsync + function rcp + if test (count $argv) -lt 2 + echo "Usage: rcp SOURCE... DESTINATION" + return 1 + end + rsync -avh --progress $argv + end + + function rmv + if test (count $argv) -lt 2 + echo "Usage: rmv SOURCE... DESTINATION" + return 1 + end + rsync -avh --progress --remove-source-files $argv + end +else + function rcp + echo "'rsync' is not installed. Install it via your package manager." + end + function rmv + echo "'rsync' is not installed. Install it via your package manager." + end +end + +if test -e /usr/bin/nano + function nanorm + if test (count $argv) -lt 1 + echo "Usage: nanorm {FILE}" + return 1 + end + nano $argv[1] + end +else + function nanorm + echo "'nano' is not installed. Install it via your package manager." + end +end + +function source --description "Source files with auto-detection (replaces builtin source)" + if test (count $argv) -eq 0 + builtin source + return + end + + set file $argv[1] + set -e argv[1] + + if string match -q -- "--*" $file + builtin source $file $argv + return + end + + if not test -f "$file" + echo "source: No such file: '$file'" >&2 + return 1 + end + + if string match -q "*.bash" -- $file + if command -q bass + bass source $file $argv + else + echo "source: 'bass' is not installed. Install it to source .bash files." >&2 + return 1 + end + else + builtin source $file $argv + end +end + +################ TERMINAL-SPECIFIC ############################################ if test "$TERM" = "xterm-kitty" alias icat='kitty +kitten icat' end +################ PYTHON ####################################################### + if test -e /usr/bin/python3 alias python='python3' alias py='python3' end -# Easier Ollama Commands -if test -e /usr/bin/ollama - alias llama_start='ollama serve' # Start the LLama server - alias llama3='ollama run llama3' # Start the LLama Chat -end - - -if test -e /usr/bin/btop - alias tasks='btop' -end - -if test -e /usr/bin/mpv - alias uni_play='mpv --vo=tct' # Plays a video in terminal with Unicode - alias asci_play='mpv --vo=caca' # Plays a video in terminal with ASCII -else - for cmd in uni_play asci_play - function $cmd - echo "You need to install mpv Inorder to use these commands: https://github.com/mpv-player/mpv" +if test -e /usr/bin/python3 + function mkvenv + if not python3 -c "import venv" ^/dev/null + echo "Python3 'venv' module is not available. Install python3-venv via your package manager." + return 1 + end + if test (count $argv) -lt 1 + echo "Usage: mkvenv {folder name}" + return 1 + end + python3 -m venv $argv[1] + if test -f $argv[1]/bin/activate.fish + source $argv[1]/bin/activate.fish + else + echo "Error: Could not find activate.fish in $argv[1]/bin/" + return 1 end end -end - - -function mkvenv - if not type -q python3 +else + function mkvenv echo "Python3 is not installed. Please install Python3 to use mkvenv." - return 1 - end - if not python3 -c "import venv" ^/dev/null - echo "Python3 'venv' module is not available. Please install it (e.g., 'python3-venv' on Debian/Ubuntu)." - return 1 - end - if test (count $argv) -lt 1 - echo "Usage: mkvenv {folder name}" - return 1 - end - python3 -m venv $argv[1] - if test -f $argv[1]/bin/activate.fish - source $argv[1]/bin/activate.fish - else - echo "Error: Could not find activate.fish in $argv[1]/bin/" - return 1 end end -function src - # Check if venv directory exists - if not test -d .venv - echo "Cannot activate: .venv directory does not exist." +if test -e /usr/bin/python3 + function src + if not test -d .venv + echo "Cannot activate: .venv directory does not exist." + return 1 + end + if not test -d .venv/bin + echo "Cannot activate: .venv/bin directory does not exist." + return 1 + end + if test -f .venv/bin/activate.fish + source .venv/bin/activate.fish + return 0 + end + if test -f .venv/bin/activate.bash + if test -e /usr/bin/bass + bass source .venv/bin/activate.bash + return 0 + else + echo "'bass' is not installed. Install it via your package manager to source bash scripts." + return 1 + end + end + echo "No usable activation script found in .venv/bin/" return 1 end - - if not test -d .venv/bin - echo "Cannot activate: .venv/bin directory does not exist." - return 1 - end - - # Prefer Fish activation script - if test -f .venv/bin/activate.fish - source .venv/bin/activate.fish - return 0 - end - - # Fallback to bash activation via bass - if test -f .venv/bin/activate.bash - bass source .venv/bin/activate.bash - return 0 - end - - echo "No usable activation script found in .venv/bin/" - return 1 -end - -# Check if eza exists in either location -if test -x /usr/bin/eza -o -x $HOME/.cargo/bin/eza - function ls - command eza -a --color=always --group-directories-first --icons $argv # Just more beautiful - end - function lr - command eza -al --color=always --group-directories-first --icons $argv # With rights and Owner - end - function ll - command eza -l --color=always --group-directories-first --icons $argv # Hidden Stuff is hidden - end - function lt - command eza -aT --color=always --group-directories-first --icons $argv # Tree View may take some time - end - function l. - command eza -ald --color=always --group-directories-first --icons .* $argv # Only Hidden Stuff - end - function lf - command eza -aD --color=always --group-directories-first --icons $argv # Only Folder - end else - # Define dummy functions that remind user to install eza + function src + echo "Python3 is not installed. Please install Python3 to use src." + end +end + +################ OLLAMA ###################################################### + +if test -e /usr/bin/ollama + alias llama_start='ollama serve' + alias llama3='ollama run llama3' +end + +################ EZA ########################################################## + +if test -x /usr/bin/eza + function ls + command eza -a --color=always --group-directories-first --icons $argv + end + function lr + command eza -al --color=always --group-directories-first --icons $argv + end + function ll + command eza -l --color=always --group-directories-first --icons $argv + end + function lt + command eza -aT --color=always --group-directories-first --icons $argv + end + function l. + command eza -ald --color=always --group-directories-first --icons .* $argv + end + function lf + command eza -aD --color=always --group-directories-first --icons $argv + end +else for cmd in lr ll lt l. lf - function $cmd + function $cmd --inherit-variable cmd echo "The command 'eza' is not installed. Please install 'eza' to use this: https://github.com/eza-community/eza" end end end -if test -e /usr/bin/ugrep - alias grep 'ugrep --color=auto' - alias egrep 'ugrep -E --color=auto' - alias fgrep 'ugrep -F --color=auto' +################ BTOP ######################################################### + +if test -e /usr/bin/btop + alias tasks='btop' +end + +################ MPV ########################################################## + +if test -e /usr/bin/mpv + alias uni_play='mpv --vo=tct' + alias asci_play='mpv --vo=caca' else - for cmd in egrep fgrep - function $cmd - echo "The command 'ugrep' is not installed. Please install 'ugrep' to use this: https://github.com/Genivia/ugrep" + for cmd in uni_play asci_play + function $cmd --inherit-variable cmd + echo "The command 'mpv' is not installed. Please install mpv to use this: https://github.com/mpv-player/mpv" end end end -if test -e /usr/bin/wget - alias wget 'wget -c ' +################ GREP ######################################################### + +if test -e /usr/bin/ugrep + alias grep='ugrep --color=auto' + alias egrep='ugrep -E --color=auto' + alias fgrep='ugrep -F --color=auto' +else + alias egrep='grep -E' + alias fgrep='grep -F' end +################ WGET ######################################################### + +if test -e /usr/bin/wget + alias wget='wget -c' +end + +################ OCRMYPDF ##################################################### + if test -e /usr/bin/ocrmypdf - alias ocrmypdf 'ocrmypdf --deskew --clean --rotate-pages' + alias ocrmypdf='ocrmypdf --deskew --clean --rotate-pages' else - alias ocrmypdf 'echo "The command 'ocrmypdf' is not installed. Please install 'ocrmypdf' to use this: https://github.com/ocrmypdf/OCRmyPDF"' -end - -function rcp - if test (count $argv) -lt 2 - echo "Usage: rcp SOURCE... DESTINATION" - return 1 + function ocrmypdf + echo "The command 'ocrmypdf' is not installed. Install it via your package manager: https://github.com/ocrmypdf/OCRmyPDF" end - rsync -avh --progress $argv end -function rmv - if test (count $argv) -lt 2 - echo "Usage: rmv SOURCE... DESTINATION" - return 1 - end - rsync -avh --progress --remove-source-files $arg -end +################ YAZI ######################################################### -function nanorm - if test (count $argv) -lt 1 - echo "Usage: nanorm {FILE}" - return 1 - end - set arg $argv[1] - if test -f $arg - rm $arg - end - nano $arg -end - -if test -e /usr/bin/reflector - alias mirror='sudo reflector -f 30 -l 30 --number 10 --verbose --save /etc/pacman.d/mirrorlist' - alias mirrora='sudo reflector --latest 50 --number 20 --sort age --save /etc/pacman.d/mirrorlist' - alias mirrord='sudo reflector --latest 50 --number 20 --sort delay --save /etc/pacman.d/mirrorlist' - alias mirrors='sudo reflector --latest 50 --number 20 --sort score --save /etc/pacman.d/mirrorlist' -end - -if test -e $HOME/.config/sway/config - alias sway_config='nano $HOME/.config/sway/config' # Open the fish Config in Text editor -end - -if test -e /usr/bin/yazi -o -e /usr/local/bin/yazi +if test -e /usr/bin/yazi function y set tmp (mktemp -t "yazi-cwd.XXXXXX") yazi $argv --cwd-file="$tmp" @@ -228,15 +264,21 @@ if test -e /usr/bin/yazi -o -e /usr/local/bin/yazi rm -f -- "$tmp" end else - function yazi - echo "The command 'yazi' is not installed. Please install 'yazi' to use this: https://github.com/sxyazi/yazi" + for cmd in yazi y + function $cmd --inherit-variable cmd + echo "The command 'yazi' is not installed. Please install 'yazi' to use this: https://github.com/sxyazi/yazi" + end end end +################ SUDO ######################################################### + if test -e /usr/bin/sudo-rs alias sudo=sudo-rs end +################ FLASH ISO #################################################### + if test -e /usr/bin/dd function flashiso --description "Flash an ISO to a target drive with dd" if test (count $argv) -ne 2 @@ -244,25 +286,6 @@ if test -e /usr/bin/dd echo "Example: flashiso ubuntu-25.10-desktop-amd64.iso /dev/sdb" return 1 end - - set iso $argv[1] - set drive $argv[2] - - sudo dd if=$iso of=$drive bs=4M status=progress oflag=sync - end -end - -#### SOURCE of bash - -function smart_source - set file $argv[1] - - if string match -q "*.bash" -- $file - bass source $file - else if string match -q "*.fish" -- $file - builtin source $file - else - # fallback: try fish source by default - builtin source $file + sudo dd if=$argv[1] of=$argv[2] bs=4M status=progress oflag=sync end end diff --git a/configs/arch_config.fish b/configs/arch_config.fish index 68429e7..c8170ee 100755 --- a/configs/arch_config.fish +++ b/configs/arch_config.fish @@ -4,13 +4,6 @@ source $HOME/.config/fish/configs/uni.fish -alias git_update='$HOME/.config/fish/scripts/git-update.sh' - -alias mount_all='$HOME/.config/fish/scripts/mount.sh' -alias umount_all='$HOME/.config/fish/scripts/umount.sh' - -alias print_cam='ssh honney@192.168.1.184' - function updateall # Get current Discord version (if installed) if pacman -Q discord >/dev/null 2>&1 @@ -35,11 +28,15 @@ function updateall set discord_version_after "" end - # Compare versions + # Compare discord versions if test "$discord_version_before" != "$discord_version_after" echo "Discord version changed: $discord_version_before -> $discord_version_after" - echo "Running extra command..." - sh -c "$(curl -sS https://raw.githubusercontent.com/Vendicated/VencordInstaller/main/install.sh)" + if test -e /usr/bin/curl + echo "Running Vencord installer..." + sh -c "$(curl -sS https://raw.githubusercontent.com/Vendicated/VencordInstaller/main/install.sh)" + else + echo "'curl' is not installed. Install it to update Discord plugins." + end end if test -e /usr/bin/flatpak @@ -57,9 +54,9 @@ function updateall set kernel_version_after "" end if test "$kernel_version_before" != "$kernel_version_after" - echo "Discord version changed: $kernel_version_before -> $kernel_version_after" + echo "Kernel changed: $kernel_version_before -> $kernel_version_after" echo -n "Reboot now? [y/N]: " - + read answer if test "$answer" = "y" -o "$answer" = "Y" @@ -70,30 +67,49 @@ function updateall end end -alias fixpacman='sudo rm /var/lib/pacman/db.lck' -alias gitpkg='pacman -Q | grep -i "\-git" | wc -l' # List amount of -git packages - +alias fixpacman='sudo rm -f /var/lib/pacman/db.lck' if test -e /usr/bin/expac - alias rip 'expac --timefmt="%Y-%m-%d %T" "%l\t%n %v" | sort | tail -200 | nl' - alias big='expac -H M "%m\t%n" | sort -h | nl' # Sort installed packages according to size in MB (expac must be installed) + alias rip='expac --timefmt="%Y-%m-%d %T" "%l\t%n %v" | sort | tail -200 | nl' + alias big='expac -H M "%m\t%n" | sort -h | nl' +else + alias rip="echo 'expac is not installed. Install it to list last deinstalled packages.'" + alias big="echo 'expac is not installed. Install it to list biggest packages.'" end + function cleanup - while pacman -Qdtq - sudo pacman -R (pacman -Qdtq) + while pacman -Qdtq >/dev/null 2>&1 + set orphans (pacman -Qdtq 2>/dev/null) + if test -z "$orphans" + break + end + sudo pacman -R $orphans + end + echo "No more orphaned packages." +end + +if test -x $HOME/.local/python-3.11.9/bin/python3.11 + alias py311="$HOME/.local/python-3.11.9/bin/python3.11" +end + +if test -e /usr/bin/tmux + function quickshell-reload + if test -e /usr/bin/quickshell + tmux kill-session -t qs 2>/dev/null + tmux new-session -d -s qs 'quickshell' + else + echo "'quickshell' is not installed. Install it via your package manager." + end + end +else + function quickshell-reload + echo "'tmux' is not installed. Install it via your package manager." end end -set -x XCURSOR_THEME "DJ-FOX-C" -set -x XCURSOR_SIZE 24 - -alias py311="$HOME/.local/python-3.11.9/bin/python3.11" - -function quickshell-reload - if test -e /usr/bin/quickshell - tmux kill-session -t qs - tmux new-session -d -s qs 'quickshell' - else - echo "quickshell not installed" - end -end +if test -e /usr/bin/reflector + alias mirror='sudo reflector -f 30 -l 30 --number 10 --verbose --save /etc/pacman.d/mirrorlist' + alias mirrora='sudo reflector --latest 50 --number 20 --sort age --save /etc/pacman.d/mirrorlist' + alias mirrord='sudo reflector --latest 50 --number 20 --sort delay --save /etc/pacman.d/mirrorlist' + alias mirrors='sudo reflector --latest 50 --number 20 --sort score --save /etc/pacman.d/mirrorlist' +end \ No newline at end of file diff --git a/configs/env.fish b/configs/env.fish index 660ac2e..6a60dc4 100644 --- a/configs/env.fish +++ b/configs/env.fish @@ -3,5 +3,5 @@ # if test -d $HOME/.bin - set -U fish_user_paths $HOME/.bin $fish_user_paths + fish_add_path $HOME/.bin end diff --git a/configs/fedora_config.fish b/configs/fedora_config.fish index 0f8e7ed..2244c41 100755 --- a/configs/fedora_config.fish +++ b/configs/fedora_config.fish @@ -5,6 +5,10 @@ alias updateall='sudo dnf upgrade --refresh && flatpak update' -if test -e $HOME/.cargo/bin/eza - set -gx PATH $HOME/.cargo/bin $PATH $PATH +if test -x $HOME/.cargo/bin/eza + fish_add_path $HOME/.cargo/bin +end + +if test -f $HOME/.config/fish/configs/uni.fish + source $HOME/.config/fish/configs/uni.fish end diff --git a/configs/theme.fish b/configs/theme.fish index 99123d9..2076fa9 100755 --- a/configs/theme.fish +++ b/configs/theme.fish @@ -1,46 +1,9 @@ -# Load pywal colors (extract from ~/.cache/wal/colors.json) -if test -e $HOME/.cache/wal/colors.json1 - set -g theme_0 (jq -r '.colors.color0' ~/.cache/wal/colors.json) # Primary color - set -g theme_1 (jq -r '.colors.color1' ~/.cache/wal/colors.json) # Secondary color (e.g., for git, @) - set -g theme_2 (jq -r '.colors.color2' ~/.cache/wal/colors.json) # Third color (e.g., for hostname) - set -g background_color (jq -r '.special.background' ~/.cache/wal/colors.json) # Background color - set -g foreground_color (jq -r '.special.foreground' ~/.cache/wal/colors.json) # Foreground color -else - set -g background_color "#1e1e2e" # Dark slate - set -g foreground_color "#cdd6f4" # Soft white/light gray - - # Primary and accent colors - set -g theme_0 "#a6e3a1" # Green - success, directories - set -g theme_1 "#f38ba8" # Red - errors, git changes - set -g theme_2 "#89b4fa" # Blue - hostnames, info - - # Extra accent colors - set -g theme_3 "#f9e2af" # Yellow - warnings - set -g theme_4 "#cba6f7" # Magenta - user prompts - set -g theme_5 "#94e2d5" # Cyan - secondary info +# load matugen-generated colors +if test -f $HOME/.config/fish/configs/colors.fish + source $HOME/.config/fish/configs/colors.fish end -# BOBTHEFISH COLORING: Apply pywal colors to the bobthefish theme - -# Username Color -set -g theme_username_color $theme_0 - -# Hostname Color -set -g theme_hostname_color $theme_2 - -# Git prompt color -set -g theme_git_branch_color $theme_1 -set -g theme_git_dirty_color $theme_1 -set -g theme_git_staged_color $theme_2 - -# Current directory color -set -g theme_pwd_color $theme_0 - -# Set background and foreground based on pywal theme -set -g theme_background_color $background_color -set -g theme_foreground_color $foreground_color - -# Retain all existing theme settings (don't overwrite the options you have) +# Bobthefish display settings set -g theme_display_git yes set -g theme_display_git_dirty no set -g theme_display_git_untracked no @@ -80,4 +43,4 @@ set -g theme_color_scheme dark set -g fish_prompt_pwd_dir_length 0 set -g theme_project_dir_length 1 set -g theme_newline_cursor yes -set -g theme_newline_prompt '$ ' +set -g theme_newline_prompt '$ ' \ No newline at end of file diff --git a/configs/ubuntu_config.fish b/configs/ubuntu_config.fish index 75e61f2..6223102 100755 --- a/configs/ubuntu_config.fish +++ b/configs/ubuntu_config.fish @@ -5,4 +5,6 @@ alias updateall='sudo apt upgrade -y && sudo apt update -y' alias uninstall='sudo apt purge -y' -source $HOME/.config/fish/configs/uni.fish +if test -f $HOME/.config/fish/configs/uni.fish + source $HOME/.config/fish/configs/uni.fish +end diff --git a/configs/uni.fish b/configs/uni.fish index 4a4fee6..de7bd5d 100644 --- a/configs/uni.fish +++ b/configs/uni.fish @@ -1,19 +1,17 @@ -if test -x /usr/bin/pacman +if command -q pacman if test -d ~/Nextcloud/UNI/26_TI/RISC-V - set -U fish_user_paths ~/Nextcloud/UNI/26_TI/RISC-V/xpack-riscv-none-elf-gcc-15.2.0-1-linux-x64/xpack-riscv-none-elf-gcc-15.2.0-1/bin $fish_user_paths - set -U fish_user_paths ~/Nextcloud/UNI/26_TI/RISC-V/verible-v0.0-4053-g89d4d98a-linux-static-x86_64/verible-v0.0-4053-g89d4d98a/bin $fish_user_paths + fish_add_path ~/Nextcloud/UNI/26_TI/RISC-V/xpack-riscv-none-elf-gcc-15.2.0-1-linux-x64/xpack-riscv-none-elf-gcc-15.2.0-1/bin + fish_add_path ~/Nextcloud/UNI/26_TI/RISC-V/verible-v0.0-4053-g89d4d98a-linux-static-x86_64/verible-v0.0-4053-g89d4d98a/bin end if test -d ~/Projects/RISC-V set -gx XILINX_VIVADO ~/Projects/RISC-V/vivado/Vivado/2022.2 - set -U fish_user_paths ~/Projects/RISC-V/vivado/Vivado/2022.2/bin $fish_user_paths + fish_add_path ~/Projects/RISC-V/vivado/Vivado/2022.2/bin set -gx LM_LICENSE_FILE ~/Projects/RISC-V/intel/LR-160568_License.dat set -gx SALT_LICENSE_SERVER $LM_LICENSE_FILE - set -U fish_user_paths ~/Projects/RISC-V/intel/questa_fse/bin $fish_user_paths + fish_add_path ~/Projects/RISC-V/intel/questa_fse/bin end end -set in_container (test -f /.dockerenv; or test -f /run/.containerenv; and echo yes; or echo no) - -if test "in_container" = yes +if test -f /.dockerenv; or test -f /run/.containerenv echo "In Container" end diff --git a/fish_variables b/fish_variables deleted file mode 100755 index 6ddf2cd..0000000 --- a/fish_variables +++ /dev/null @@ -1,7 +0,0 @@ -# This file contains fish universal variable definitions. -# VERSION: 3.0 -SETUVAR __done_min_cmd_duration:5000 -SETUVAR __done_notify_sound:1 -SETUVAR __done_sway_ignore_visible:0 -SETUVAR __fish_initialized:4300 -SETUVAR fish_user_paths:/home/honney/Projects/RISC\x2dV/intel/questa_fse/bin\x1e/home/honney/Projects/RISC\x2dV/vivado/Vivado/2022\x2e2/bin\x1e/home/honney/Nextcloud/UNI/26_TI/RISC\x2dV/verible\x2dv0\x2e0\x2d4053\x2dg89d4d98a\x2dlinux\x2dstatic\x2dx86_64/verible\x2dv0\x2e0\x2d4053\x2dg89d4d98a/bin\x1e/home/honney/Nextcloud/UNI/26_TI/RISC\x2dV/xpack\x2driscv\x2dnone\x2delf\x2dgcc\x2d15\x2e2\x2e0\x2d1\x2dlinux\x2dx64/xpack\x2driscv\x2dnone\x2delf\x2dgcc\x2d15\x2e2\x2e0\x2d1/bin\x1e/home/honney/\x2ebin\x1e/opt/rocm/bin diff --git a/functions/addpaths.fish b/functions/addpaths.fish index 389adca..57d9350 100644 --- a/functions/addpaths.fish +++ b/functions/addpaths.fish @@ -1,5 +1,12 @@ function addpaths - contains -- $argv $fish_user_paths - or set -U fish_user_paths $fish_user_paths $argv + if test (count $argv) -lt 1 + echo "Usage: addpaths [more paths...]" + return 1 + end + for p in $argv + if not contains -- $p $fish_user_paths + fish_add_path -U $p + end + end echo "Updated PATH: $PATH" end diff --git a/functions/compare_sha256.fish b/functions/compare_sha256.fish deleted file mode 100755 index 627951d..0000000 --- a/functions/compare_sha256.fish +++ /dev/null @@ -1,15 +0,0 @@ -function compare_sha256 - if test (count $argv) -ne 2 - echo "Usage: compare_sha256 " - return 1 - end - - set hash1 (sha256sum $argv[1] | awk '{print $1}') - set hash2 (sha256sum $argv[2] | awk '{print $1}') - - if test "$hash1" = "$hash2" - echo "Match" - else - echo "Different" - end -end diff --git a/functions/extract.fish b/functions/extract.fish index db1471b..8080297 100755 --- a/functions/extract.fish +++ b/functions/extract.fish @@ -1,14 +1,18 @@ -function extract +function extract --description "Extract various archive formats" if test (count $argv) -lt 1 echo "Usage: extract [output_directory]" return 1 end + if not command -q file + echo "extract: 'file' command is required. Install it via your package manager." + return 1 + end + set archives $argv set output_dir "." set use_custom_dir 0 - # If exactly 2 args and second is a directory (or doesn't exist yet), treat it as output dir if test (count $argv) -eq 2 set maybe_dir $argv[2] if test -d "$maybe_dir"; or not test -e "$maybe_dir" @@ -19,7 +23,6 @@ function extract end end - # Detect multiple archives set multi 0 if test (count $archives) -gt 1 set multi 1 @@ -31,10 +34,8 @@ function extract continue end - # Determine base name (strip extensions) - set base (string replace -r '\.(tar\.gz|tgz|tar\.bz2|tbz2|tar\.xz|txz|gz|bz2|xz|zst|zip|7z|rar)$' '' (basename "$archive")) + set base (string replace -r '\.(tar\.(gz|bz2|xz|zst)|tar|tgz|tbz2|txz|tzst|gz|bz2|xz|zst|zip|7z|rar)$' '' (basename "$archive")) - # Decide target directory if test $multi -eq 1 set target_dir "$base" else if test $use_custom_dir -eq 1 @@ -43,30 +44,134 @@ function extract set target_dir "$base" end - mkdir -p "$target_dir" - set mime (file --mime-type -b "$archive") switch $mime case 'application/x-tar' + if not command -q tar + echo "extract: 'tar' is not installed. Install it via your package manager." + continue + end + mkdir -p "$target_dir" tar -xvf "$archive" -C "$target_dir" + echo "extract: extracted '$archive' to '$target_dir'" + case 'application/gzip' - tar xvzf "$archive" -C "$target_dir" + if string match -q '*.tar.gz' -- "$archive"; or string match -q '*.tgz' -- "$archive" + if not command -q tar + echo "extract: 'tar' is not installed. Install it via your package manager." + continue + end + mkdir -p "$target_dir" + tar -xzf "$archive" -C "$target_dir" + echo "extract: extracted '$archive' to '$target_dir'" + else + if not command -q gzip + echo "extract: 'gzip' is not installed. Install it via your package manager." + continue + end + set outname (string replace -r '\.gz$' '' (basename "$archive")) + gzip -dkc "$archive" > "$output_dir/$outname" + echo "extract: decompressed '$archive' to '$output_dir/$outname'" + end + case 'application/x-bzip2' - tar xvjf "$archive" -C "$target_dir" + if string match -q '*.tar.bz2' -- "$archive"; or string match -q '*.tbz2' -- "$archive" + if not command -q tar + echo "extract: 'tar' is not installed. Install it via your package manager." + continue + end + mkdir -p "$target_dir" + tar -xjf "$archive" -C "$target_dir" + echo "extract: extracted '$archive' to '$target_dir'" + else + if not command -q bzip2 + echo "extract: 'bzip2' is not installed. Install it via your package manager." + continue + end + set outname (string replace -r '\.bz2$' '' (basename "$archive")) + bzip2 -dkc "$archive" > "$output_dir/$outname" + echo "extract: decompressed '$archive' to '$output_dir/$outname'" + end + case 'application/x-xz' - tar xvJf "$archive" -C "$target_dir" + if string match -q '*.tar.xz' -- "$archive"; or string match -q '*.txz' -- "$archive" + if not command -q tar + echo "extract: 'tar' is not installed. Install it via your package manager." + continue + end + mkdir -p "$target_dir" + tar -xJf "$archive" -C "$target_dir" + echo "extract: extracted '$archive' to '$target_dir'" + else + if not command -q xz + echo "extract: 'xz' is not installed. Install it via your package manager." + continue + end + set outname (string replace -r '\.xz$' '' (basename "$archive")) + xz -dkc "$archive" > "$output_dir/$outname" + echo "extract: decompressed '$archive' to '$output_dir/$outname'" + end + case 'application/zstd' - tar --zstd -xvf "$archive" -C "$target_dir" + if string match -q '*.tar.zst' -- "$archive"; or string match -q '*.tzst' -- "$archive" + if not command -q tar + echo "extract: 'tar' is not installed. Install it via your package manager." + continue + end + mkdir -p "$target_dir" + tar --zstd -xvf "$archive" -C "$target_dir" + echo "extract: extracted '$archive' to '$target_dir'" + else + if not command -q zstd + echo "extract: 'zstd' is not installed. Install it via your package manager." + continue + end + set outname (string replace -r '\.zst$' '' (basename "$archive")) + zstd -dkc "$archive" > "$output_dir/$outname" + echo "extract: decompressed '$archive' to '$output_dir/$outname'" + end + case 'application/zip' + if not command -q unzip + echo "extract: 'unzip' is not installed. Install it via your package manager (e.g., 'unzip' on most distros)." + continue + end + mkdir -p "$target_dir" unzip "$archive" -d "$target_dir" + echo "extract: extracted '$archive' to '$target_dir'" + case 'application/x-7z-compressed' - 7z x "$archive" -o"$target_dir" + if command -q 7z + mkdir -p "$target_dir" + 7z x "$archive" -o"$target_dir" + echo "extract: extracted '$archive' to '$target_dir'" + else if command -q 7zz + mkdir -p "$target_dir" + 7zz x "$archive" -o"$target_dir" + echo "extract: extracted '$archive' to '$target_dir'" + else + echo "extract: '7z' or '7zz' is not installed. Install p7zip via your package manager." + continue + end + case 'application/x-rar' 'application/vnd.rar' - unrar x -o+ "$archive" "$target_dir" + if command -q unrar + mkdir -p "$target_dir" + unrar x -o+ "$archive" "$target_dir/" + echo "extract: extracted '$archive' to '$target_dir'" + else if command -q rar + mkdir -p "$target_dir" + rar x -o+ "$archive" "$target_dir/" + echo "extract: extracted '$archive' to '$target_dir'" + else + echo "extract: 'unrar' or 'rar' is not installed. Install unrar via your package manager." + continue + end + case '*' echo "extract: unknown file type for '$archive' ($mime)" continue end end -end \ No newline at end of file +end diff --git a/functions/findstr.fish b/functions/findstr.fish index fec0674..fd524cc 100644 --- a/functions/findstr.fish +++ b/functions/findstr.fish @@ -3,8 +3,14 @@ function findstr echo "Usage: findstr " return 1 end + if not command -q find + echo "findstr: 'find' is not installed." + return 1 + end + if not command -q grep + echo "findstr: 'grep' is not installed." + return 1 + end - set query $argv[1] - - find . -type f -exec grep -Hn "$query" {} \; + find . -type f -exec grep -Hn "$argv[1]" {} \; end diff --git a/functions/fish_prompt.fish_bak b/functions/fish_prompt.fish_bak deleted file mode 100755 index 9f347e4..0000000 --- a/functions/fish_prompt.fish_bak +++ /dev/null @@ -1,15 +0,0 @@ -# Load pywal colors -set -g theme_0 (jq -r '.colors.color0' ~/.cache/wal/colors.json) # Color0 for general text -set -g theme_1 (jq -r '.colors.color1' ~/.cache/wal/colors.json) # Color1 for highlights (e.g., @ symbol) -set -g theme_2 (jq -r '.colors.color2' ~/.cache/wal/colors.json) # Color2 for hostname -set -g background_color (jq -r '.special.background' ~/.cache/wal/colors.json) # Background color -set -g foreground_color (jq -r '.special.foreground' ~/.cache/wal/colors.json) # Foreground color - -# Customize your prompt -function fish_prompt - # Set background and foreground colors - echo -n (set_color $background_color) # Set background color - echo -n (set_color $foreground_color) # Set foreground color for text - echo -n (set_color $theme_0) 'user' (set_color $theme_1) '@' (set_color $theme_2) 'host' (set_color normal) '> ' -end - diff --git a/functions/pack.fish b/functions/pack.fish index 95a11b2..1fa9fd5 100755 --- a/functions/pack.fish +++ b/functions/pack.fish @@ -3,12 +3,15 @@ function pack echo "Usage: pack [more files...]" return 1 end + if not command -q tar + echo "pack: 'tar' is not installed. Install it via your package manager." + return 1 + end set archive $argv[1] set targets $argv[2..-1] - # Ensure .tar.xz extension - if not string match -r '\.tar\.xz$' -- $archive + if not string match -q '*.tar.xz' -- $archive set archive "$archive.tar.xz" end diff --git a/functions/removepath.fish b/functions/removepath.fish index 5bd6f26..608a461 100644 --- a/functions/removepath.fish +++ b/functions/removepath.fish @@ -1,8 +1,12 @@ function removepath + if test (count $argv) -lt 1 + echo "Usage: removepath " + return 1 + end if set -l index (contains -i $argv[1] $PATH) set --erase --universal fish_user_paths[$index] - echo "Updated PATH: $PATH" + echo "Removed '$argv[1]' from PATH." else - echo "$argv[1] not found in PATH: $PATH" + echo "'$argv[1]' not found in PATH." end end diff --git a/functions/search.fish b/functions/search.fish index bc62a2b..4c10647 100644 --- a/functions/search.fish +++ b/functions/search.fish @@ -3,10 +3,13 @@ function search echo "Usage: search [directory]" return 1 end + if not command -q rg + echo "search: 'rg' (ripgrep) is not installed. Install it via your package manager." + return 1 + end set query $argv[1] set dir "." - if test (count $argv) -ge 2 set dir $argv[2] end diff --git a/functions/verify_file.fish b/functions/verify_file.fish new file mode 100644 index 0000000..31f1d67 --- /dev/null +++ b/functions/verify_file.fish @@ -0,0 +1,55 @@ +function verify_file + if test (count $argv) -ne 2 + echo "Usage: verify_file " + return 1 + end + + set file $argv[1] + if not test -f "$file" + echo "verify_file: '$file' is not a valid file" + return 1 + end + + set expected $argv[2] + set len (string length "$expected") + + switch $len + case 32 + set cmd md5sum + case 40 + set cmd sha1sum + case 56 + set cmd sha224sum + case 64 + set cmd sha256sum + case 96 + set cmd sha384sum + case 128 + if command -q sha512sum + set cmd sha512sum + else if command -q b2sum + set cmd b2sum + else + echo "verify_file: no tool available for 128-char hash (sha512sum or b2sum required)" + return 1 + end + case '*' + echo "verify_file: unknown hash length ($len chars). Supported: md5(32), sha1(40), sha224(56), sha256(64), sha384(96), sha512/b2(128)" + return 1 + end + + if not command -q $cmd + echo "verify_file: '$cmd' is not installed." + return 1 + end + + set actual ($cmd "$file" | string split -f1 " ") + + if test "$actual" = "$expected" + echo "Match" + return 0 + else + echo "Mismatch" + return 1 + end +end diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..c126ae2 --- /dev/null +++ b/install.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +set -euo pipefail + +detect_pkg_manager() { + if command -v apt &>/dev/null; then + echo "apt" + elif command -v dnf &>/dev/null; then + echo "dnf" + elif command -v pacman &>/dev/null; then + echo "pacman" + elif command -v zypper &>/dev/null; then + echo "zypper" + else + echo "unknown" + fi +} + +install_fish() { + local pm + pm=$(detect_pkg_manager) + case "$pm" in + apt) + sudo apt update && sudo apt install -y fish + ;; + dnf) + sudo dnf install -y fish + ;; + pacman) + sudo pacman -S --noconfirm fish + ;; + zypper) + sudo zypper install -y fish + ;; + *) + echo "No supported package manager found. Please install fish manually: https://fishshell.com" + exit 1 + ;; + esac +} + +install_omf() { + if [ ! -d "$HOME/.local/share/omf" ]; then + echo "Installing Oh My Fish..." + curl https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install > install + fish install --path=~/.local/share/omf --config=~/.config/omf + else + echo "Oh My Fish already installed." + fi +} + +install_bobthefish() { + if command -v fish &>/dev/null && [ -f "$HOME/.local/share/omf/init.fish" ]; then + echo "Installing bobthefish theme..." + fish -c 'omf install bobthefish' + fi +} + +set_default_shell() { + local fish_path + fish_path=$(command -v fish) + if [ "$SHELL" != "$fish_path" ]; then + echo "Setting default shell to fish..." + if grep -q "^$USER:" /etc/passwd 2>/dev/null; then + chsh -s "$fish_path" + else + echo "Run this manually: chsh -s $fish_path" + fi + else + echo "Fish is already your default shell." + fi +} + +main() { + install_fish + install_omf + install_bobthefish + set_default_shell + + echo + echo "=== Installation complete ===" + echo "Log out and back in, or run: exec fish" +} + +main