Skip to content

Commit

Permalink
Fishline v3.2.1 (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
0rax committed Nov 8, 2020
2 parents fe142bd + 0f864db commit fddaa10
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 22 deletions.
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,49 @@

This framework uses a lot of glyph from Powerline fonts in order to work, you will need to install one of them and select it as your shell font to enjoy this software completely. More information about how to install them can be found in the [Powerline wiki](https://powerline.readthedocs.io/en/latest/installation.html#fonts-installation).


## Installation

### Manually

In order to install fishline, you will need to clone this repository somewhere and specify this path in your `config.fish` file as well as sourcing the `init.fish` file present from the repository.

Here is an example on how to do it, by cloning `fishline` in your `~/.config/fish` folder:

```sh
git clone https://github.com/0rax/fishline.git/ ~/.config/fish/fishline
```

Then modify your `~/.config/fish/config.fish` and add:

```sh
set FLINE_PATH $HOME/.config/fish/fishline
source $FLINE_PATH/init.fish
if status is-interactive
set FLINE_PATH $HOME/.config/fish/fishline
source $FLINE_PATH/init.fish
end
```
### Using [Fisherman](https://github.com/fisherman/fisherman)
### Using [Fisher](https://github.com/jorgebucaran/fisher)
This is the easiest way to install `fishline` in your fish-shell environment. Fisherman will install it and link all the needed functions for you by running the following command:
```sh
fisher i 0rax/fishline
fisher add 0rax/fishline
```
This will allow you to use the `fishline` command directly and access to all the possible theming / configuration available as if you installed it manually.
## Configuration
To use fishline as your prompt, update or create a `fish_prompt.fish` file in your `functions` folder (`~/.config/fish/functions` by default) to include:
Now call the fishline function with your last status in your `fish_prompt` function
```sh
function fish_prompt
fishline -s $status
end
```
[More informations about installation and configuration available in the wiki.](https://github.com/0rax/fishline/wiki "Fishline Wiki")
## License
fishline is MIT licensed. See [LICENSE](LICENSE).
19 changes: 11 additions & 8 deletions init.fish
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ if test -z "$FLINE_PATH"
end
end

# Use FLINE_PATH to load internals, functions and segments
if [ "$FLINE_PATH" = "$HOME/.config/fish/conf.d" -a -d "$HOME/.config/fisherman/fishline" ]
# Assumes fishline has been installed using fisherman on system without realpath
set -gx FLINE_PATH $HOME/.config/fisherman/fishline
set -gx fish_function_path $fish_function_path $FLINE_PATH/internals $FLINE_PATH/segments
else
# Standard installation, add function loading path
set -gx fish_function_path $fish_function_path $FLINE_PATH/functions $FLINE_PATH/internals $FLINE_PATH/segments
if not set -q FLINE_INIT
set -g FLINE_INIT true
# Use FLINE_PATH to load internals, functions and segments
if [ "$FLINE_PATH" = "$HOME/.config/fish/conf.d" -a -d "$HOME/.config/fisherman/fishline" ]
# Assumes fishline has been installed using fisherman on system without realpath
set -gx FLINE_PATH $HOME/.config/fisherman/fishline
set -ga fish_function_path $FLINE_PATH/internals $FLINE_PATH/segments
else
# Standard installation, add function loading path
set -ga fish_function_path $FLINE_PATH/functions $FLINE_PATH/internals $FLINE_PATH/segments
end
end

# Load default color theme based on tput output
Expand Down
4 changes: 4 additions & 0 deletions internals/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Internals

## Internal functions

- `__fishline_segment`
Expand Down Expand Up @@ -67,6 +68,9 @@
- `FLINE_PROMPT`
- Possible values: list of segment
- Used by: `fishline`
- `FLINE_INIT`
- Possible values: `true`
- Used by: `init.fish`

## Segment initialization variables (initialized for the session)

Expand Down
12 changes: 6 additions & 6 deletions segments/__flseg_exectime.fish
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ function __flseg_exectime

__fishline_segment $FLCLR_EXECTIME_BG $FLCLR_EXECTIME_FG

set -l ms (math "$duration%1000")
set -l ms (math "$duration%1000")
if [ $duration -gt 36000000 ]
set -l h (math "$duration/36000000")
set -l min (math "$duration/60000%60")
set -l h (math --scale=0 "$duration/36000000")
set -l min (math --scale=0 "$duration/60000%60")
printf "%sh %sm" $h $min
else if [ $duration -gt 60000 ]
set -l min (math "$duration/60000")
set -l s (math "$duration/1000%60")
set -l min (math --scale=0 "$duration/60000")
set -l s (math --scale=0 "$duration/1000%60")
printf "%sm %ss" $min $s
else if [ $duration -gt 1000 ]
set -l s (math "$duration/1000")
set -l s (math --scale=0 "$duration/1000")
printf "%ss %sms" $s $ms
else
printf "%sms" $ms
Expand Down
4 changes: 2 additions & 2 deletions tests/run.fish
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ while [ (count $args) -ge 0 ]
end

# Init fishline
set -l FLINE_PATH (git rev-parse --show-toplevel)
set FLINE_PATH (git rev-parse --show-toplevel)
source $FLINE_PATH/init.fish
set -l fish_function_path $fish_function_path $FLINE_PATH/tests
set -a fish_function_path $FLINE_PATH/tests

# Get segment list to check
if [ "$all_seg" = "true" ]
Expand Down

0 comments on commit fddaa10

Please sign in to comment.