Git Product home page Git Product logo

pureline's People

Contributors

abhijitvalluri avatar acidnik avatar akd5027 avatar alastair-smith avatar amirsil avatar andresrinivasan avatar bug-ware avatar chris-marsh avatar cyrilotheningirard avatar darkvertex avatar dzamlo avatar funollet avatar glitsj16 avatar kazanami avatar levaitamas avatar literacyfanatic avatar mogenson avatar rockandska avatar soobinrho avatar tparsons01 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pureline's Issues

Using Control Characters resets the cursor

An addendum to the initial concern: This only seems to occur within tmux

using Ctrl+L to reset the terminal resets the cursor location back one space
using Ctrl+U to clear the terminal line up to the PS1 does the same thing

git module colors

it would appear that the git module ignores the colors given in the config file and always uses MyOrange

On some systems the prompt line wraps and overwrites the original line (without adding a new line)

Hello! I'm using your pureline code to beautify my prompts. Thanks for your work!

I've installed the current latest git version, but I still have an issue on a Ubuntu 20.04 system. I'm using xfce-term4 and I ssh from a Ubuntu 20.04 system. I'm using the same config line on both systems. On my local system line wrapping works correctly. Over ssh, with pureline enabled, it doesn't work correctly for the first line!
Here is my config: https://paste.ubuntu.com/p/fDsKPmq68B/

 adrianp  ~  $  echo 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890
1234567890 1234567890 1234567890 1234567890 1234567890 1234567890
 adrianp  ~  $  
 adrianp  ~  $  ssh frost-vpn
... Banner omitted for brevity ...
Last login: Thu Mar 18 10:28:29 2021 from 192.168.1.11
 adrianp  💻 frost  ~  $             
34567890  💻 frost  ~  $  echo 1234567890 1234567890 1234567890 12 
1234567890 1234567890 1234567890 1234567890

Any suggestions what I should be looking for?
Thanks!

Merging PR #66 reintroduced a bug in __pureline_pre

2 days ago, merging PR #66 "Allowing TMUX pane titles to persist" reintroduced this bug that I fixed in merged PR #72 "Fixes when inherited PROMPT_COMMAND is not empty" :

[FIX-1]
function 'pureline_pre' now returns the saved error code of the last executed command.
=> Does not break an inherited PROMPT_COMMAND that requires that value.

Please merge #83 "Don't set the GUI window title if PL_TITLEBAR is empty" to cleanly solve that issue.

Background jobs count wrong

pureline is now always showing a single job running in the background. I've traced the issue to the fact that I have PROMPT_COMMAND="cat $XDG_CACHE_HOME/wal/sequences" in my bashrc. The issue isn't specific to that file; cat itself seems to be the problem.

Git Segment - too many external calls to the git command

Need to improve the performance of the git segment.

git_branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null)
number_stash=$(git stash list 2>/dev/null
number_behind_ahead=$(git rev-list --count --left-right '@{upstream}...HEAD')
number_staged=$(git diff --staged --name-only --diff-filter=AM)
number_conflicts=$(git diff --name-only --diff-filter=U)
number_modified=$(git diff --name-only --diff-filter=M)
number_untracked=$(git ls-files --other --exclude-standard)
git status --porcelain # to determine dirty status

8 calls to git (plus wc and tr for those calls). Most of this could be reduced to a single call to git status ---porcelain --branch and parsing the result.

Replace spaces for Unix output of wc in git_module

This SO answer explains why OSX (and others) always output a set number of spaces from wc. As a result, git_module on OSX is almost unusable as-is, as the line contains many unnecessary spaces.

Proposal:

Pipe the output of every wc command to sed 's/^ *//' in order to ensure spaces are trimmed.

Add tmux, hg segments

See patch - just two files in segments/. Hg support is pretty dumb for now, tmux support uses tmux display -p so it can expand to pretty much anything you want.

diff --git a/segments/hg_segment b/segments/hg_segment
new file mode 100644
index 0000000..6377b59
--- /dev/null
+++ b/segments/hg_segment
@@ -0,0 +1,47 @@
+#!/usr/bin/env bash
+
+# hg segment
+
+# Set default symbols if not already defined in config
+# Defaults should be standard symbols.
+[[ -z ${PL_SYMBOLS[hg_branch]} ]] && PL_SYMBOLS[hg_branch]="╬"
+
+# -----------------------------------------------------------------------------
+# append to prompt: hgbranch with indicators for;
+#     number of; modified files, staged files and conflicts
+# arg: $1 background color
+# arg: $2 foreground color
+# option variables;
+#   PL_HG_UNTRACKED: true/false
+function hg_segment {
+    which hg >/dev/null 2>&1 || return;  ## return if no hg
+
+    local hg_branch="$(hg branch 2>/dev/null)"
+
+    [[ -z $hg_branch ]] && return; ## return early if not a branch/no info
+
+	local bg_color="$1"
+	local fg_color="$2"
+	local content="${PL_SYMBOLS[hg_branch]} $hg_branch"
+
+	if [[ $PL_HG_UNTRACKED == true ]]; then
+    	local number_untracked="$(hg status -u -T ".\n" | wc -l | tr -d '[:space:]')"
+    	if (( number_untracked != 0 )); then
+        	content+=" ${PL_SYMBOLS[soft_separator]} ${PL_SYMBOLS[hg_untracked]}$number_untracked"
+    	fi
+	fi
+
+	if [[ -n "$(hg status 2>/dev/null)" ]]; then
+    	if [[ -v PL_HG_DIRTY_FG ]]; then
+        	fg_color="$PL_HG_DIRTY_FG"
+    	fi
+    	if [[ -v PL_HG_DIRTY_BG ]]; then
+        	bg_color="$PL_HG_DIRTY_BG"
+    	fi
+	fi
+
+	PS1+="$(segment_end "$fg_color" "$bg_color")"
+	PS1+="$(segment_content "$fg_color" "$bg_color" " $content ")"
+	__last_color="$bg_color"
+}
+
diff --git a/segments/tmux_segment b/segments/tmux_segment
new file mode 100644
index 0000000..c8518df
--- /dev/null
+++ b/segments/tmux_segment
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+#
+# tmux_segment
+#
+
+# Set default symbols if not already defined in config.
+# Defaults should be standard symbols.
+
+[[ -z ${PL_SYMBOLS[tmux_session]} ]] && PL_SYMBOLS[tmux_session]='♆'
+[[ -z ${PL_SYMBOLS[tmux_window]} ]] && PL_SYMBOLS[tmux_window]='▢'
+# -----------------------------------------------------------------------------
+# append to prompt: tmux session name
+# arg: $1 background color
+# arg: $2 foreground color
+# option variables;
+#   PL_TMUX_WINDOW: true/false, append window name
+
+function tmux_session_segment {
+    [[ ! -v TMUX ]] && return;  ## return if $TMUX not set
+	which tmux >/dev/null 2>&1 || return; ## return if no 'tmux'
+
+    local bg_color="$1"
+    local fg_color="$2"
+    local content="${PL_SYMBOLS[tmux_session]} #{session_name}"
+
+    if [[ $PL_TMUX_WINDOW ]]; then
+        content+=" ${PL_SYMBOLS[tmux_window]} #{window_name}"
+    fi
+
+    content="$(tmux display -p "$content")"
+
+    PS1+="$(segment_end "$fg_color" "$bg_color")"
+    PS1+="$(segment_content "$fg_color" "$bg_color" " $content ")"
+    __last_color="$bg_color"
+}
+
+

Kubernetes segment spams "error: current-context is not set" if kubectl available but not configured yet

When the command exists but kubernetes has no context currently configured, kubectl config current-context prints error: current-context is not set into the stderr.

It's annoying and can be bypassed by disabling the Kubernetes segment temporarily HOWEVER I think it may be worth fixing here:
https://github.com/chris-marsh/pureline/blob/main/segments/kubernetes_segment#L12
and changing it for:

        local context=$(kubectl config current-context 2>/dev/null)

to silence the stderr (because you have the exit code and stdout will be empty when not set, so it's superfluous.)

Running on a Pi (bash version 5.0.3)

Hi there,

I am having problems getting this going on a Pi, this is the error I am getting

-bash: PROMPT_COMMAND: line 0: syntax error near unexpected token `;'
-bash: PROMPT_COMMAND: line 0: `pureline_pre; [[ -w '/tmp/dietpi-process.pid' ]] && rm -f /tmp/dietpi-process.pid &> /dev/null && echo -ne '\r\e[J'; ; pureline_ps1;'

It is odd because it works fine on Pop OS (bash version 5.1.16) and Debian 11 (bash version 5.1.4).

If you want me to test any code changes then I am happy to do so, I tried to debug the problem myself but I could not get it working.

Many thanks

Jason

Issue when ssh-ing to a macOS with pureline

When I ssh to a macOS machine which has pureline configured, I get the following error message after every single command:

-bash: ip: command not found

This doesn't seem to affect anything as far as I can notice. The workaround is to install ip on OS X as described here:

brew install iproute2mac

I'm not expecting a fix, but wanted to at least share the workaround where everyone encountering the problem might look for it first.

Unicode symbols

Hi folks, I've got a problem with the Unicode symbols, for some reason they decided not to show up
image

"bash: [: true: integer expression expected" inside path_module

image
Bash complains about a test comparison inside path_module with incorrect operator introduced in commit 1045000d00b03041878e9b4c47653d19f593f52d

Printing the $3 value when inside path_module shows that this variable holds a boolean value instead of an integer one. Don't know if this has to be that way though.
image

Reverting the changes of said commit fixes bash complaints about the correct use of the operator inside the test.

Bash version:
GNU bash, version 4.4.19(1)-release (x86_64-unknown-linux-gnu)

I'd gladly provide more information if needed.

EDIT: Strangely, I have not been able to reproduce this on a friend's machine. I fear that this might not be a pureline bug.

Adding a \n before the prompt IS A FUCKING NIGHTMARE

Hi, i've been sitting here for the last HALF A FUCKING HOUR, trying to add a fucking \n before your command prompt.
I'VE TRIED EVERYTHING, but nothing seems to work. Right now my terminal has the same utility of Windows troubleshooter

Please HELP

Return code module - Output not displayed

Hi,

The return code module does not display output on CentOS7 and RHEL8 with bash versions 4.2.46(2) and 4.4.19(1) respectively.
CentOS7_Capture
RHEL8_Capture

But it displays output properly on Bash on Ubuntu on Windows (WSL) with bash version 4.4.20(1)
WSL

Is this a known issue?

Thanks guys.

segments are not found

Hello, I am having an issue with the pureline package that I recently installed. I followed the documentation and moved the pureline directory to .config/terminal/pureline and the .pureline.conf file to the same directory. However, when I try to run pureline, I am getting an error that states:

-bash: battery_segment: command not found -bash: ssh_segment: command not found -bash: screen_session_segment: command not found -bash: virtual_env_segment: command not found -bash: conda_env_segment: command not found -bash: aws_profile_segment: command not found -bash: kubernetes_segment: command not found -bash: git_segment: command not found -bash: duration_segment: command not found
I am new to terminal and would appreciate any help in resolving this issue.

Installation for all users?

Is there any hints / howto on how to install this for all users?

I would get that the source should exist in /etc/profile.d/something

Then install under /usr/local? or /opt?

Doesn't work on macOS

Your ../pureline/pureline config declares dictionaries in bash with -A, so this doesn't work and even after correcting this the display looks like this:

screen shot 2018-04-12 at 9 14 39 pm

I even configured a Powerline font thinking that could be the issue but no luck.

Challenged trying to create a module for iterm2 prompt

Given iterm2, iterm2 shell integration, and the following included in my pureline configuration

function iterm2_mark_module {
    if [ -n "$__last_color" ]; then
        PS1+="$(section_end $__last_color 'Default')"
    fi
    PS1+="\[$(iterm2_prompt_mark)\]"
    unset __last_color
}

function newline_module {
    if [ -n "$__last_color" ]; then
        PS1+="$(section_end $__last_color 'Default')"
    fi
    PS1+="\n\[$(iterm2_prompt_mark)\]"
    unset __last_color
}

# All modules are enabled. Uncomment/comment to enable/disable a module
declare -a PL_MODULES=(
    # Module                Background  Foreground
    'time_module            MyLightGrey Black'
#    'battery_module         MyBlue      Black'
#    'user_module            MyLime      Black'
    'ssh_module             MyYellow    Black'
    'virtual_env_module     MyBlue      Black'
    'path_module            MyBlue      Black'
    'read_only_module       MyRed       White'
    'background_jobs_module MyPurple    White'
    'git_module             MyGreen     Black'
    'return_code_module     MyRed       White'
    'newline_module'
#    'iterm2_mark_module'
    'prompt_module          MyDarkGrey  White'
)

This configuration puts the prompt mark on the newline as desired with the replaced newline_module. But if I comment out my override and enable iterm2_mark_module in PL_MODULES, the prompt mark doesn't move to the newline.

But why?

duration_segment broken in macOS

Under macOS duration_segment fails with

-bash: (1638285455N: value too great for base (error token is "1638285455N")

This is because macOS's native date doesn't support %N. I tried installing coreutils from brew, but that installs it as gdate by default. At this point, there's 2 workarounds that I could think of:

  1. replace date with gdate in duration_segment

  2. (which I ended up using, suggested by brew) prepend PATH with /usr/local/opt/coreutils/libexec/gnubin to make the binaries installed by coreutils have precedence over macOS native ones

Not sure what a proper fix would be, just leaving this here for others running into it.

Fix: BAT1 not working

I don't know yet how to make a pull request.
However, I just recognized that the battery module throws up path not found errors for BAT1 because of a typo in the file pureline/pureline in line 274:

batt_dir=$batt_dir1""

should read:

batt_dir=$batt_dir"1"

SSH module?

I fail to understand how the SSH module is supposed to work.
If I SSH into another machine, I simply see the plain shell prompt of that machine - without any of the fancy pureline modifications. What am I missing?

Similarly, the root module seems to do nothing. As soon as I issue SU, the shell reverts to the standard prompt.

Am I supposed to additionally install pureline on the servers I SSH into and for the root account itself respectively?

Sorry for sounding dumb. I'm familiar with bash, but never played around much with command line prompt customization.

Multiline commands are visually broken

If $PL_ERASE_LINE=true as it does by default, multiline commands break when recalled from history. As soon as you add or remove a character from the first line of the command, the entire line will disappear from view.

Pretty broken in OSX

I use Pureline on Linux and WSL shells all the time but I recently tried to deploy it on an OSX box I ssh to sometimes and it's completely broken. :(

If it helps, my default shell is Bash (version 3.2.57), running on Darwin 20.3.0 (aka Big Sur), using the latest "main" branch:

alan@hitchcock:~$  source $HOME/repos/pureline/pureline
-bash: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
-bash: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
\e]2;'\u@\h: \w' alan@hitchcock ↔ ~ ↔

I guess it's probably because the Bash bundled with OSX is very old, maybe:

alan@hitchcock:~$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin20)
Copyright (C) 2007 Free Software Foundation, Inc.

(My WSL Ubuntu environment where Pureline works perfectly has Bash 4.2 copyright 2011, for comparison.)

Phantom bg job

String 30 in /pureline/segments/git_segment give subj.
Reason: cyrillic locale. Job status "Done" naming as "Завершен".
Fix: add "local LC_MESSAGES=C" in "background_jobs_segment" function.

Right align segments

How do I configure a segment (like time, battery) to get aligned to the right side of terminal?

Broken README install instructions

README install instructions say to do:

$ cd ~
$ git clone https://github.com/chris-marsh/pureline.git
$ cp pureline/example-config.conf ~/.pureline.conf

But the file example-config.conf is no longer there. I later understood there's example configs under the /configs subdirectory.

It would be nice if the README was edited to give correct instructions and also explain how the various example configs provided are different.

Show $SHLVL in prompt if greater than 1

I think it would be useful to have the prompt show the shell level.
This is probably more useful when you messing about with things like PureLine dev :) I'm constantly sourcing pureline or starting new bash sessions to test stuff. Working my way back with Ctrl-D is tricky to know when your at ground zero.

Prompt segment could be

|$> bash
|2$> bash
|3$> bash
|4$> ctrl-d
|2$> ctrl-d
|$>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.