reobin / typewritten

A minimal, lightweight, informative zsh prompt theme

Home Page:https://typewritten.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Usage with Antibody

johnletey opened this issue · comments

Is your feature request related to a problem? Please describe.

I have a list of all my Zsh plugins (including typewritten):

# ~/.dotfiles/zsh/plugins.txt

zsh-users/zsh-autosuggestions branch:develop
zsh-users/zsh-syntax-highlighting
#mafredri/zsh-async
#sindresorhus/pure
reobin/typewritten

In my Zsh config, I have the following:

# ~/.zshrc

source <(antibody init)
antibody bundle < ~/.dotfiles/zsh/plugins.txt

source ~/.dotfiles/zsh/env.zsh
source ~/.dotfiles/zsh/alias.zsh

However, I get the following (an unstyled prompt):

Screenshot 2020-06-04 at 09 58 19

Describe the solution you'd like

I would like to be able to use typewritten with Antibody.

Describe alternatives you've considered

I guess I could switch my entire setup over to oh-my-zsh, but I don't want to do that just for a prompt theme.

Additional context

N/A

Hi @jletey !
Thank you for the suggestion.

I have not heard of antibody but making typewritten standalone (no zsh or oh-my-zsh) is something I have had in mind for a while.

From what I understand, your request would remove oh-my-zsh as a dependency, and it is a step in the right direction for me.

Could you link to some themes that do support antibody?

@reobin Awesome really glad to hear this!

The only other theme that I’ve used with Antibody, is pure. But I’m sure there are many others out there :)

Hey @jletey !

So I researched a little with my limited time, and this will have to be a pretty big change. Any help on this would be appreciated. 😅

Essentially, we need to turn this into an independent zsh bundle which could be consumed by any zsh package manager like Antibody, or Antigen.

Spaceship and Pure are good examples we could follow.

If you have a little time, you could help me identify the steps we need to take to make this a zsh bundle independent of oh-my-zsh.

Cheers!

@reobin More than happy to take a look at this! I'll let you know what I find :)

@jletey

So I created a branch called feat/zsh-bundle, where I created a file typewritten.zsh which is still WIP (missing features), but works without oh-my-zsh.

Only thing missing for this new file to work with a package manager is the typewritten.plugin.zsh file which is also a symlink to the theme. Shouldn't be a problem whatsoever.

I added the manual instructions for now to install the oh-my-zshless theme. I think we can start building on that to add the features missing. I don't have more time for today to work on it but this is what is missing:

  • colors
  • git status indicator
  • maybe export each feature in its own file to keep the main file cleaner

Tell me if what you find makes sense with what I've done so far. And maybe help me run some tests with antibody, as I don't use it 😅 (after adding the typewritten.plugin.zsh symlink file)

Later!

So I couldn't help myself, and kept working 😅 It wasn't that much work actually!

Got to implement all the features old typewritten had. And now it doesn't need oh-my-zsh, which is great.

As I said, I added the instructions on how to manually install the theme.. I'd like to have another opinion on this, and a check if it actually works.

Also, I'll need some help writing the instructions on how to install it with a package manager, if it works. If it doesn't, we can identify what is wrong.

I'd like to have another opinion on this, and a check if it actually works.

@reobin Thx so much for working on this 🙏

Screenshot 2020-06-09 at 08 30 50

The only thing that is missing is the directory 🤔

Other than that it works amazing 😍

If it doesn't, we can identify what is wrong.

@reobin When using the latest code with Antibody, it unfortunately doesn't work :/

# ~/.dotfiles/zsh/plugins.txt

zsh-users/zsh-autosuggestions branch:develop
zsh-users/zsh-syntax-highlighting
#mafredri/zsh-async
#sindresorhus/pure
reobin/typewritten branch:feat/zsh-bundle

I don't rlly know what's the problem, it seems like it loads? Because the cursor is changed 🤔

Now that I think of it the cursor has always been changed 🤔

Screenshot 2020-06-09 at 12 37 05

There seems to be a problem with the git part of the prompt

Hmm, I'll take a look as the current directory display works fine on my end.

About antibody, did you create the symlink file called typewritten.plugin.zsh?

Hmm, I'll take a look as the current directory display works fine on my end.

Alright, thx again for working on this :)

About antibody, did you create the symlink file called typewritten.plugin.zsh?

I'll try that, IMO, I think it's worthwhile to push the symlink to the branch.

Current directory part was a dumb mistake 😅 You can pull and it should work.

I now also pushed the symlink plugin file, tell me how that works for you. I'll do some tests too.

Maybe I end up liking antibody.

Got it to work with these lines in my .zshrc:

source <(antibody init)
antibody bundle reobin/typewritten branch:feat/zsh-bundle

Struggled a little bit at first because I has pulled the master branch, and just specifying another branch later didn't update the local repo pulled by antibody.

and just specifying another branch later didn't update the local repo pulled by antibody.

Haha yep just realised that 😅 I now have it working with Antibody 🎉 I can help submit a PR to add instructions on how to install.

Also, seems as tho there is a hick-up with git rn:

Screenshot 2020-06-09 at 14 19 01

When I'm in the ~/Desktop/release dir, the git status shows fine. However when I'm inside ~/Desktop/release/app, it errors, even tho I'm still in the same git repo.

So one of the way the prompt checks for a git repository is to check if the .git repository exists.

I will remove this check and just keep the git rev-parse command.

Could you pull and test again?

Screenshot 2020-06-09 at 16 43 48

Now it's failing in the git dir and the sub-dir

Wow ahah

Are you sure everything is up to date? No check should be done for the .git directory.

The code for the typewritten_is_git_repository function looks like this:

typewritten_is_git_repository() {
  if $(command git rev-parse --git-dir 2> /dev/null); then
    echo true
  else
    echo false
  fi
}

Screenshot 2020-06-09 at 17 22 38

Yeah it's updated! Still not working. And when I run cat lib/git.zsh, the updated code is there:

Screenshot 2020-06-09 at 17 25 18

That is weird. Could you try on another repo?

or run this: command git rev-parse --git-dir 2> /dev/null in your repo and see what pops up?

Basically, command git rev-parse --git-dir 2> /dev/null returns the path of the .git directory if you are in a git repo, and returns nothing if not.

I updated the condition, maybe it runs better now.

Run antibody update. If not, I am puzzled as it works perfectly on my side 🤔

maybe it runs better now.

Wuhuu!!! It works!!! 🎉 Thx for debugging this!

Run antibody update.

Ah I feel stupid 😅 Thx for the tip

Good news!

Next steps:

I'll update the readme, so it's more readable.

When you got a little bit of spacetime, could you come up with the docs on how to install it with various package managers?
I'm thinking of antigen and antibody, but maybe more if it actually works.

I think common ways to install a prompt theme are:

  • prezto
  • zim
  • antigen
  • antibody
  • zgen
  • zplug

You could try a couple, write the docs, and make a PR with the target branch to be feat/zsh-bundle.
When we merge, you would show up as a contributor.

I'll help with some package managers, but I want you to show up in the contributor list! 🎉

could you come up with the docs on how to install it with various package managers?

I'd be more than happy too!

but I want you to show up in the contributor list! 🎉

🤗