Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

functions.fish -- trim-right ++string trim #7

Open
carakesa opened this issue Jul 31, 2023 · 0 comments
Open

functions.fish -- trim-right ++string trim #7

carakesa opened this issue Jul 31, 2023 · 0 comments

Comments

@carakesa
Copy link

carakesa commented Jul 31, 2023

I didn't realize the string manipulation was part of Fish, so this took me a bit to get partially working.

trim-right is deprecated, but changing it to string trim -c .zip seems to work.

I do get a warning:

fish: Unknown command: is-clean-zip ~/.config/fish/functions/functions.fish (line 37): if is-clean-zip $zipfile

But everything still seems to work still, so I'm not sure what this bit was supposed to do!

Here's the code as I have it now.


# Clean unzip: Creates a top level folder if a zip file doesn't have one
# This prevents the directory from being cluttered with unzipped files
function clean-unzip --argument zipfile
    if not test (echo $zipfile | string sub --start=-4) = .zip
        echo (status function): argument must be a zipfile
        return 1
    end

    if is-clean-zip $zipfile
        unzip $zipfile
    else
        set zipname (echo $zipfile | string trim -c .zip)
        mkdir $zipname || return 1
        unzip $zipfile -d $zipname
    end
end

# unzip-cd utilizes clean-unzip to unzip and cd into a zip file
function unzip-cd --argument zipfile
    clean-unzip $zipfile && cd (echo $zipfile | string trim -c .zip)
end


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant