hykilpikonna / hyfetch

🏳️‍🌈 🏳️‍⚧️ Neofetch with LGBTQ+ pride flags!
MIT License
1.18k stars 93 forks source link

Help custom ascii #198

Closed TheCuteOwl closed 9 months ago

TheCuteOwl commented 9 months ago

Hi i want to put a custom ascii when i do hyfetch (without having to put --ascii (path) is this possible (i'm on windows)

hykilpikonna commented 9 months ago

If you're running hyfetch using powershell, you can actually set any default arguments to any command by editing powershell profile.

  1. Open powershell
  2. Open an editor to edit $PROFILE (e.g. code $PROFILE for vscode)
  3. Write the following:
function Start-Hyfetch {
    hyfetch --ascii-file 'C:\your\path\to\ascii.txt'
}
Set-Alias -Name hyfetch -Value Start-Hyfetch
  1. Restart powershell
hykilpikonna commented 9 months ago

I'll close this for now, please let me know if it works or if you run into any issues.

TheCuteOwl commented 9 months ago
oh-my-posh init pwsh --config 'C:\Users\myusername\AppData\Local\Programs\oh-my-posh\themes\1_shell.omp.json' | Invoke-Expression

function Start-Hyfetch {
    hyfetch --ascii-file 'C:\Users\myusername\Downloads\ascii-art (3).txt'
}
Set-Alias -Name hyfetch -Value Start-Hyfetch

image

there is nothing showing up maybe you could help me for cmd?

hykilpikonna commented 9 months ago

Oops okay I created an recursive loop on accident. Here is the correct way to do it: (https://stackoverflow.com/questions/70828336/adding-arguments-to-powershell-alias-functions)

function hyfetch {
    # Get executable path to one commnad named hyfetch
    $bin = (Get-Command -Type Application hyfetch -TotalCount 1).Source
    # Define additional arguments as a list
    $add = ("--ascii-file", 'C:\Users\myusername\Downloads\ascii-art (3).txt')

    if ($MyInvocation.ExpectingInput) { # pipeline (stdin) input present
        # $args passes all arguments through.
        $input | & $bin $add $args
    } else {
        & $bin $add $args
    }
}

Tested with Powershell 7.3.8 (on macOS)

Why does a simple alias hyfetch="hyfetch --ascii-file ..." in bash have to be so verbose in powershell 🙃

TheCuteOwl commented 9 months ago

thanks ! it work perfectly now