diff --git a/.gitignore b/.gitignore index a3633e2..5a71f1d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ configs/colors.fish -fish_variables \ No newline at end of file +fish_variables +themes \ No newline at end of file diff --git a/conf.d/00_fisher_path.fish b/conf.d/00_fisher_path.fish new file mode 100644 index 0000000..7d4a399 --- /dev/null +++ b/conf.d/00_fisher_path.fish @@ -0,0 +1,20 @@ +# 1. Point to your custom Fisher repository +set -gx fisher_path ~/.config/fisher +if test -d $fisher_path + # 2. Append the custom folders to Fish's native search lists if they aren't already there + if not contains $fisher_path/functions $fish_function_path + set fish_function_path $fisher_path/functions $fish_function_path + end + + if not contains $fisher_path/completions $fish_complete_path + set fish_complete_path $fisher_path/completions $fish_complete_path + end + + # 3. Simulate the conf.d execution by natively sourcing third-party configuration files + for file in $fisher_path/conf.d/*.fish + if not test -s $file + continue + end + source $file + end +end \ No newline at end of file diff --git a/config.fish b/config.fish index 14d44a9..23e9bdd 100755 --- a/config.fish +++ b/config.fish @@ -1,6 +1,10 @@ # Replace frozen key bindings migration (deletes fish_frozen_key_bindings.fish) set --global fish_key_bindings fish_default_key_bindings +# +# for fisher: ~/.config/fish/conf.d/00_fisher_path.fish +# + if status is-interactive # Get distro ID from /etc/os-release if test -f /etc/os-release diff --git a/configs/alias_fixing.fish b/configs/alias_fixing.fish index abb4885..06c457c 100755 --- a/configs/alias_fixing.fish +++ b/configs/alias_fixing.fish @@ -7,7 +7,40 @@ if test "$TERM" = "xterm-kitty"; or test "$TERM" = "alacritty" alias ssh='env TERM=xterm-256color ssh' end -if command -q zoxide - zoxide init fish | source - alias cd='z' +# if command -q zoxide +# zoxide init fish | source +# alias cd='z' +# end + +set -gx fisher_path ~/.config/fisher + +################ FIX STEAM #################################################### + +function steam_fix + if test -f /usr/share/applications/steam.desktop + # Check if the credential helper is already in the file + if ! grep -q "PrefersNonDefaultGPU=true" -q '/X-KDE-RunOnDiscreteGpu=true' /usr/share/applications/steam.desktop + echo "Steam is allready fixed" + else + echo "Fixing Steam" + # Remove the specific GPU lines using sudo and sed + sudo sed -i -e '/PrefersNonDefaultGPU=true/d' -e '/X-KDE-RunOnDiscreteGpu=true/d' /usr/share/applications/steam.desktop + echo "Steam has been fixed." + end + else + echo "no /usr/share/applications/steam.desktop file" + echo "could not fix steam" + end end + +################ FIX BRAVE #################################################### + +function brave_fix + if test -f ~/.config/BraveSoftware/Brave-Browser/SingletonLock + # Check if the credential helper is already in the file + rm ~/.config/BraveSoftware/Brave-Browser/SingletonLock + else + echo "Brave not blocked by SingletonLock" + echo "could not fix brave" + end +end \ No newline at end of file diff --git a/configs/alias_useful.fish b/configs/alias_useful.fish index 56d8805..29ab268 100755 --- a/configs/alias_useful.fish +++ b/configs/alias_useful.fish @@ -8,7 +8,14 @@ alias remount='sudo mount -a' alias mount_config='sudo nano /etc/fstab' alias own='sudo chown -R "$USER":"$USER"' alias right='sudo chmod -R 755' -alias reload='clear && omf reload' +function reload + if command -q omf + omf reload + else + clear + exec fish + end +end alias fish_config='nano $HOME/.config/fish/config.fish' alias ip='ip -color' alias psmem='ps auxf | sort -nr -k 4' @@ -71,33 +78,82 @@ else end function source --description "Source files with auto-detection (replaces builtin source)" - if test (count $argv) -eq 0 - builtin source + # --- 0. Handle standard input piping (Fixes background script sourcing) --- + if not isatty stdin + builtin source $argv return end - set file $argv[1] - set -e argv[1] - - if string match -q -- "--*" $file - builtin source $file $argv + # --- 1. Handle Flags First --- + if test (count $argv) -gt 0; and string match -q -- "--*" $argv[1] + builtin source $argv return end - if not test -f "$file" - echo "source: No such file: '$file'" >&2 - return 1 - end + # --- 2. Check: Is a file/argument given? --- + if test (count $argv) -gt 0 + set file $argv[1] + set -e argv[1] - 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 + # Check if the explicit path actually exists as a file + if not test -f "$file" + echo "source: No such file: '$file'" >&2 return 1 end + + # Logic: Is it .fish? + if string match -q "*.fish" -- $file + builtin source $file $argv + return + # Logic: Is it .bash? + else if string match -q "*.bash" -- $file or string match -q "*.sh" -- $file + if command -q bass + bass source $file $argv + return + else + echo "source: 'bass' is not installed. Install it to source bash files." >&2 + return 1 + end + # Logic: Else (unknown file type) + else + echo "source: Unknown file extension for '$file'. Please specify a .fish or .bash file." >&2 + return 1 + end + + # --- 3. No file given: Check for local venv directories --- else - builtin source $file $argv + # Target directories to check in order of preference + set venv_dirs .venv venv + + for dir in $venv_dirs + if test -d "$dir" + # Check for .fish activator first + if test -f "$dir/bin/activate.fish" + builtin source "$dir/bin/activate.fish" + return + + # Check for .bash activator second + else if test -f "$dir/bin/activate" or test -f "$dir/bin/activate.bash" + # Resolve which bash file exists + set bash_act "$dir/bin/activate" + if test -f "$dir/bin/activate.bash" + set bash_act "$dir/bin/activate.bash" + end + + if command -q bass + bass source $bash_act + return + else + echo "source: Found bash virtual env in '$dir', but 'bass' is not installed." >&2 + return 1 + end + end + end + end + + # Logic: Else error (No venv found and no args provided) + echo "source: No file specified and no local venv or .venv directory found." >&2 + return 1 end end @@ -306,23 +362,4 @@ function git_cred echo "no .git/config file" echo "could not add the credentials helper" end -end - -################ FIX STEAM #################################################### - -function steam_fix - if test -f /usr/share/applications/steam.desktop - # Check if the credential helper is already in the file - if ! grep -q "PrefersNonDefaultGPU=true" -q '/X-KDE-RunOnDiscreteGpu=true' /usr/share/applications/steam.desktop - echo "Steam is allready fixed" - else - echo "Fixing Steam" - # Remove the specific GPU lines using sudo and sed - sudo sed -i -e '/PrefersNonDefaultGPU=true/d' -e '/X-KDE-RunOnDiscreteGpu=true/d' /usr/share/applications/steam.desktop - echo "Steam has been fixed." - end - else - echo "no /usr/share/applications/steam.desktop file" - echo "could not fix steam" - end end \ No newline at end of file diff --git a/fish_plugins b/fish_plugins new file mode 100644 index 0000000..403e4eb --- /dev/null +++ b/fish_plugins @@ -0,0 +1,15 @@ +jorgebucaran/fisher +jorgebucaran/humantime.fish +ilancosman/tide@v6 +patrickf1/fzf.fish +franciscolourenco/done +jhillyerd/plugin-git +icezyclon/zoxide.fish +jorgebucaran/spark.fish +meaningful-ooo/sponge +jorgebucaran/autopair.fish +nickeb96/puffer-fish +mattmc3/magic-enter.fish +gazorby/fish-abbreviation-tips +lgathy/google-cloud-sdk-fish-completion +ankitsumitg/docker-fish-completions diff --git a/functions/pack.fish b/functions/pack.fish old mode 100755 new mode 100644 diff --git a/install.sh b/install.sh index c126ae2..78f40e5 100755 --- a/install.sh +++ b/install.sh @@ -72,7 +72,7 @@ set_default_shell() { main() { install_fish - install_omf + install_omf # add way to choose fisher and add ln -s $fisher_path/themes $__fish_config_dir/themes install_bobthefish set_default_shell