From: Steve Dondley <s@dondley.com>
To: zsh-users@zsh.org
Subject: Re: Best practices for managing aliases in ohmyzsh?
Date: Tue, 31 Aug 2021 11:51:49 -0400 [thread overview]
Message-ID: <1ee1545904fdc1b5f473460cddfe5000@dondley.com> (raw)
In-Reply-To: <CAN=4vMo0w_YLudqC-byGHy11i1EBn_oMrJrQ-Qt4VZEd6vL7WQ@mail.gmail.com>
On 2021-08-31 04:26 AM, Roman Perepelitsa wrote:
> On Tue, Aug 31, 2021 at 1:23 AM Steve Dondley <s@dondley.com> wrote:
>>
>> Now you've got me wondering. While I was bumbling around today, I
>> noticed I had an ~/.oh-my-zsh/.zshrc file.
>
> This is unexpected. Oh My Zsh installer does not create this file.
>
>> I'm only using the ~/.zshrc file, though. It has just one line:
>> ZSH_THEME="powerlevel9k/powerlevel9k". I'm guessing that's the
>> default because I don't remember editing it.
>
> The default theme in Oh My Zsh is "robbyrussell". powerlevel9k is not
> included in Oh My Zsh. The fact that you are using it means you've
> installed it separately (or copied a config from someone else who
> did).
>
> Note that development of powerlevel9k has been discontinued and the
> project has been archived.
>
> On Tue, Aug 31, 2021 at 3:30 AM Steve Dondley <s@dondley.com> wrote:
>>
>> Right. I had hunted around for an ohmyzsh list but didn't find one
>> (but
>> if you know of one, let me know).
>
> Oh My Zsh uses Discord for questions and discussions of this kind. You
> can find a link at https://ohmyz.sh/.
>
>> > In general, zsh will not run bash code 100% correctly unless it is
>> > written *extremely* portably. Your old functions almost certainly
>> > need to be tweaked to one degree or another.
>>
>> My functions are very simple so I haven't run into any problems yet.
>> But
>> I will definitely keep this in mind going forward.
>
> This suggests that all or at least most of your functions could be
> scripts instead. Place each one in a separate executable file in a
> directory in your PATH (~/bin is a common choice), slap a shebang on
> each and you are good to go. This way you can use your utilities from
> any shell and won't have to port them whenever you switch shells.
> Since these utilities are proven to work in bash, use `#!/usr/bin/env
> bash` as shebang. You *can* also make them auto-loadable functions in
> zsh but you probably shouldn't. The only advantage would be that
> they'll execute faster but that matters only in rare special cases.
> The disadvantage is that you would have to port your scripts to zsh,
> make sure they can run with various shell options, don't pollute
> interactive shell environment, etc,
>
> Roman.
OK, thanks Roman. This all sounds like good advice has got me rethinking
things.
But I'm a little confused on a point you made. What do you consider the
difference to be between a script and a function? My functions are
typically called with aliases that I've set up. Example:
# usage: taskwarrior_cmd
# description: runs a task warrior command
cmd=${1}
shift
id=${1}
#echo $id;
shift
echo $cmd;
#echo $@
echo task $id ${cmd}$@
task $id ${=cmd}$@
#echo $cmd
if [[ "$cmd" =~ ^done ]]; then
task +st and \(+imm or +OVERDUE\) next
fi
Do you consider this to be a function or a script? I have this in a file
in my ~/.ohmyzsh functions directory. I don't call this function
directly, it is only called from an alias that looks something like
this:
alias tdep="taskwarrior_cmd 'modify depends:'"
next prev parent reply other threads:[~2021-08-31 15:52 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-30 18:13 Steve Dondley
2021-08-30 22:27 ` Ray Andrews
2021-08-30 23:22 ` Steve Dondley
2021-08-30 23:34 ` Ray Andrews
2021-08-31 1:44 ` Steve Dondley
2021-08-31 0:14 ` Lawrence Velázquez
2021-08-31 1:29 ` Steve Dondley
2021-08-31 8:26 ` Roman Perepelitsa
2021-08-31 15:51 ` Steve Dondley [this message]
2021-08-31 17:57 ` Roman Perepelitsa
2021-08-31 18:54 ` Bart Schaefer
2021-08-31 21:22 ` Steve Dondley
2021-08-31 21:36 ` Roman Perepelitsa
2021-08-31 21:43 ` Steve Dondley
2021-08-31 21:44 ` Roman Perepelitsa
2021-09-01 0:12 ` Ray Andrews
2021-09-01 0:28 ` Bart Schaefer
2021-09-01 2:33 ` Ray Andrews
2021-09-01 3:01 ` Bart Schaefer
2021-09-01 14:20 ` Daniel Shahaf
2021-09-01 15:58 ` Ray Andrews
2021-09-01 18:22 ` Lawrence Velázquez
2021-09-01 19:11 ` Ray Andrews
2021-09-01 19:16 ` Bart Schaefer
2021-09-01 19:56 ` Ray Andrews
2021-09-01 20:03 ` Bart Schaefer
2021-09-01 20:52 ` Steve Dondley
2021-09-01 21:06 ` Ray Andrews
2021-09-01 22:06 ` Steve Dondley
2021-09-01 20:53 ` Lawrence Velázquez
2021-09-01 21:11 ` zeurkous
2021-09-01 21:19 ` Bart Schaefer
2021-09-01 21:29 ` Lawrence Velázquez
2021-09-01 21:23 ` Ray Andrews
2021-09-01 21:05 ` Ray Andrews
2021-09-01 3:19 ` Steve Dondley
2021-09-01 3:30 ` Bart Schaefer
2021-09-01 3:27 ` Lawrence Velázquez
2021-09-01 16:20 ` Ray Andrews
2021-09-01 18:34 ` Lawrence Velázquez
2021-09-01 19:19 ` Ray Andrews
2021-08-31 8:06 ` Anssi Saari
2021-08-31 15:45 ` Steve Dondley
2021-08-31 16:24 ` zzapper
2021-08-31 16:47 ` Steve Dondley
2021-08-31 17:20 ` Steve Dondley
2021-08-31 17:26 ` Bart Schaefer
2021-08-31 17:40 ` Steve Dondley
2021-08-31 17:47 ` Steve Dondley
2021-08-31 18:31 ` Ray Andrews
2021-08-31 18:59 ` Lawrence Velázquez
2021-09-01 6:40 ` Michael Klemm
2021-09-01 22:13 ` Steve Dondley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1ee1545904fdc1b5f473460cddfe5000@dondley.com \
--to=s@dondley.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).