10000 functions.fish -- trim-right ++string trim · Issue #7 · GideonWolfe/dots · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
functions.fish -- trim-right ++string trim #7
Open
@carakesa

Description

@carakesa

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


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0