starship / starship

☄🌌️ The minimal, blazing-fast, and infinitely customizable prompt for any shell!
https://starship.rs
ISC License
44.18k stars 1.92k forks source link

[wish] TMUX status line integration #4835

Open tigerinus opened 1 year ago

tigerinus commented 1 year ago

Feature Request

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

No.

Describe the solution you'd like

The only reason I am still staying with Powerline is its integration with TMUX. I've been looking for an alternative to Powerline + TMUX + bash for a long time, but no luck. Starship has a cross-shell prompt customizer that seems to be promising. It'd be nice to support TMUX.

Describe alternatives you've considered

https://github.com/gpakosz/.tmux

tigerinus commented 1 year ago

There are some discussions about this topic at https://github.com/JanDeDobbeleer/oh-my-posh/issues/475

tigerinus commented 1 year ago

A naive thought on this is:

  1. Have starship prompt --tmux and starship prompt --right --tmux to write current left and right prompt to status bar based on TMUX format.

    Something like (except currently it does not write in TMUX format) image

  2. Have a starship-daemon to call the above commands on regular basis (per 2 sec, e.g.), ONLY if currently running inside TMUX (check if $TMUX is set)

  3. Optionally the right prompt could be hidden if $TMUX is set - just to eliminate redundant information on the screen.

davidkna commented 1 year ago

Starship currently uses an external library to handle ANSI text coloring, so it's unlikely we will support tmux formatting anytime soon. For now, it would make sense to instead write a daemon that rewrites ANSI colors into the tmux format and refreshes the status line as desired. This would also work with other similar prompts like ohmyposh.

tigerinus commented 1 year ago

Starship currently uses an external library to handle ANSI text coloring, so it's unlikely we will support tmux formatting anytime soon. For now, it would make sense to instead write a daemon that rewrites ANSI colors into the tmux format and refreshes the status line as desired. This would also work with other similar prompts like ohmyposh.

That's actually a good idea. I've created a feature request to TMUX.

carboncrystal commented 1 year ago

@tigerinus For me Starship is integrated with TMUX + bash and I can't find any customization from the Starship base terminal that doesn't work with TMUX. In addition I also use Tmuxinator (to easily manage TMUX sessions via a .yml file) and it works as well.

I think I know why some people fail to integrate Starship with TMUX:

~/.bashrcsettings is not being sourced via TMUX! TMUX runs as a login Shell so it looks for a .bash_profile file or a .bash_login file and colours were being set in ~/.bashrc file. This happens to all users (advanced users) who use / have ~/.bash_profile or ~/.bash_login files!

Solution:

  1. Add source ~/.bashrc to your .bash_profile file! (recommended to be added at the beginning)
  2. If you have already opened several TMUX sessions: Select / Attach in TMUX the main (new opened session) and kill all other opened TMUX sessions tmux kill-ses -a
  3. Source from terminal the bash files: source ~/.bashrc and source ~/.bash_profile
  4. Start TMUX and source his config file: source ~/.tmux.conf (check location of your TMUX config file, maybe you have it in the .config folder).
  5. Don't forget: if you restart your OS or your TMUX server you must source again only TMUX config file: source ~/.tmux.conf (point 4).

Starship will work perfectly with TMUX. All settings from your Starship config file will work without problems in TMUX, e.g: colours, icons, Git Status, etc.

Proof that Starship works with TMUX:

Screenshot from 2023-03-12 17-27-47

davidkna commented 1 year ago

@carboncrystal believe this issue concerns using starship for/in the tmux status line in the bottom (please have a look at the screenshot above).