help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to rename files to numbers in Eshell?


From: Emanuel Berg
Subject: Re: How to rename files to numbers in Eshell?
Date: Thu, 30 Sep 2021 09:50:00 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Jean Louis wrote:

> For me, shell scripts are in Elisp and usually used in Dired
> rather than Eshell.
>
> Pipes may be replaced by buffers, capturing information in
> a buffer and processing it thereafter.

Elisp and Bash are not close so one might as well start
over ...

If you insist, here are some zsh for you to practice on.

So tell me, what's the Elisp equivalent of:

#! /bin/zsh

create-100-meg-bogus-file () {
    local file=${1:-100.data}
    rm $file
    dd if=/dev/urandom         \
       of=$file                \
       count=$(( 1024 * 100 )) \
       bs=1024 | sha256sum | ( read rnd _; echo $rnd >> $file )
}

and

#! /bin/zsh

t () {
    # check number of arguments
    if [[ $# == 0 ]]; then
        echo "syntax: $0 COMMAND" >&2
        return
    fi

    local cmd=$1

    find-zsh-command $cmd

    # use whence; if a path, do 'ls'
    local whence_hits
    whence_hits=("${(@f)$(whence -ca $cmd | sed "s#$HOME#~#g")}")
    local  h
    for h in $whence_hits; do
        echo $h
        ls -Ghl --color=auto $h 2> /dev/null
        if [ -h $h ]; then
            local dest=$(readlink -e $h)
            set-fg-color 3
            echo -n " * links to: "
            reset-color
            echo -n $dest '\n             '
            ls -Ghl --color=auto $dest
        fi
    done

    # if a script, output it
    cats $cmd
}

?

The whole file (323 lines)

  https://dataswamp.org/~incal/conf/.zsh/files-fs

After that only ~99 more and you are all set :)

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]