mirror of
https://github.com/buckley310/nixos-config.git
synced 2024-11-09 18:47:02 +00:00
powerline: remove SHLVL
This commit is contained in:
parent
924bd2ce00
commit
a47ccab21c
4 changed files with 2 additions and 149 deletions
|
@ -87,7 +87,6 @@
|
||||||
enable = true;
|
enable = true;
|
||||||
terminal = "screen-256color";
|
terminal = "screen-256color";
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
set-environment -gu SHLVL
|
|
||||||
bind-key j command-prompt -p "Join pane:" "join-pane -s '%%'"
|
bind-key j command-prompt -p "Join pane:" "join-pane -s '%%'"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,7 +23,7 @@ in
|
||||||
args = lib.mkOption {
|
args = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.str;
|
type = lib.types.listOf lib.types.str;
|
||||||
default = [
|
default = [
|
||||||
"-modules=\${remote:+'user,host,'}nix-shell,shlvl,git,jobs,cwd"
|
"-modules=\${remote:+'user,host,'}nix-shell,git,jobs,cwd"
|
||||||
"-git-assume-unchanged-size 0"
|
"-git-assume-unchanged-size 0"
|
||||||
"-theme ${theme}"
|
"-theme ${theme}"
|
||||||
"-path-aliases '~/git=~/git'"
|
"-path-aliases '~/git=~/git'"
|
||||||
|
@ -38,21 +38,7 @@ in
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
|
|
||||||
environment.systemPackages = [
|
environment.systemPackages = [ pkgs.powerline-go ];
|
||||||
((pkgs.callPackage
|
|
||||||
(pkgs.fetchurl
|
|
||||||
{
|
|
||||||
url = "https://raw.githubusercontent.com/NixOS/nixpkgs/6ce4a720012398d451c21bc042d6740e92289615/pkgs/tools/misc/powerline-go/default.nix";
|
|
||||||
sha256 = "7a8294ac9726da9531f1e506369233b051ecc6aa32c77a281f7167027a89977e";
|
|
||||||
}
|
|
||||||
)
|
|
||||||
{ }
|
|
||||||
).overrideAttrs (old: {
|
|
||||||
patches = [
|
|
||||||
./shlvl.patch
|
|
||||||
];
|
|
||||||
}))
|
|
||||||
];
|
|
||||||
|
|
||||||
programs.bash.interactiveShellInit = ''
|
programs.bash.interactiveShellInit = ''
|
||||||
function _update_ps1() {
|
function _update_ps1() {
|
||||||
|
|
|
@ -1,128 +0,0 @@
|
||||||
From 40a4883fbc225f2f568431b295fc66d294bf7f7d Mon Sep 17 00:00:00 2001
|
|
||||||
From: Sean Buckley <sean.bck@gmail.com>
|
|
||||||
Date: Thu, 23 Dec 2021 20:19:02 -0500
|
|
||||||
Subject: [PATCH] add segment-shlvl
|
|
||||||
|
|
||||||
---
|
|
||||||
README.md | 6 +++---
|
|
||||||
defaults.go | 3 +++
|
|
||||||
main.go | 1 +
|
|
||||||
segment-shlvl.go | 23 +++++++++++++++++++++++
|
|
||||||
themes.go | 3 +++
|
|
||||||
themes/default.json | 2 ++
|
|
||||||
6 files changed, 35 insertions(+), 3 deletions(-)
|
|
||||||
create mode 100644 segment-shlvl.go
|
|
||||||
|
|
||||||
diff --git a/README.md b/README.md
|
|
||||||
index cd47e90..edde09c 100644
|
|
||||||
--- a/README.md
|
|
||||||
+++ b/README.md
|
|
||||||
@@ -248,12 +248,12 @@ Usage of powerline-go:
|
|
||||||
(default "patched")
|
|
||||||
-modules string
|
|
||||||
The list of modules to load, separated by ','
|
|
||||||
- (valid choices: aws, bzr, cwd, direnv, docker, docker-context, dotenv, duration, exit, fossil, gcp, git, gitlite, goenv, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, rbenv, root, rvm, shell-var, shenv, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo, vi-mode, wsl)
|
|
||||||
+ (valid choices: aws, bzr, cwd, direnv, docker, docker-context, dotenv, duration, exit, fossil, gcp, git, gitlite, goenv, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, rbenv, root, rvm, shell-var, shenv, shlvl, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo, vi-mode, wsl)
|
|
||||||
Unrecognized modules will be invoked as 'powerline-go-MODULE' executable plugins and should output a (possibly empty) list of JSON objects that unmarshal to powerline-go's Segment structs.
|
|
||||||
(default "venv,user,host,ssh,cwd,perms,git,hg,jobs,exit,root")
|
|
||||||
-modules-right string
|
|
||||||
The list of modules to load anchored to the right, for shells that support it, separated by ','
|
|
||||||
- (valid choices: aws, bzr, cwd, direnv, docker, docker-context, dotenv, duration, exit, fossil, gcp, git, gitlite, goenv, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, rbenv, root, rvm, shell-var, shenv, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo, wsl)
|
|
||||||
+ (valid choices: aws, bzr, cwd, direnv, docker, docker-context, dotenv, duration, exit, fossil, gcp, git, gitlite, goenv, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, rbenv, root, rvm, shell-var, shenv, shlvl, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo, wsl)
|
|
||||||
Unrecognized modules will be invoked as 'powerline-go-MODULE' executable plugins and should output a (possibly empty) list of JSON objects that unmarshal to powerline-go's Segment structs.
|
|
||||||
-newline
|
|
||||||
Show the prompt on a new line
|
|
||||||
@@ -266,7 +266,7 @@ Usage of powerline-go:
|
|
||||||
Use '~' for your home dir. You may need to escape this character to avoid shell substitution.
|
|
||||||
-priority string
|
|
||||||
Segments sorted by priority, if not enough space exists, the least priorized segments are removed first. Separate with ','
|
|
||||||
- (valid choices: aws, bzr, cwd, direnv, docker, docker-context, dotenv, duration, exit, fossil, gcp, git, gitlite, goenv, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, rbenv, root, rvm, shell-var, shenv, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo, vi-mode, wsl)
|
|
||||||
+ (valid choices: aws, bzr, cwd, direnv, docker, docker-context, dotenv, duration, exit, fossil, gcp, git, gitlite, goenv, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, rbenv, root, rvm, shell-var, shenv, shlvl, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo, vi-mode, wsl)
|
|
||||||
(default "root,cwd,user,host,ssh,perms,git-branch,git-status,hg,jobs,exit,cwd-path")
|
|
||||||
-shell string
|
|
||||||
Set this to your shell type
|
|
||||||
diff --git a/defaults.go b/defaults.go
|
|
||||||
index 83c91ad..3857828 100644
|
|
||||||
--- a/defaults.go
|
|
||||||
+++ b/defaults.go
|
|
||||||
@@ -262,6 +262,9 @@ var defaults = Config{
|
|
||||||
ShEnvFg: 15,
|
|
||||||
ShEnvBg: 130,
|
|
||||||
|
|
||||||
+ ShLvlFg: 231,
|
|
||||||
+ ShLvlBg: 55,
|
|
||||||
+
|
|
||||||
NodeFg: 15,
|
|
||||||
NodeBg: 40,
|
|
||||||
NodeVersionFg: 40,
|
|
||||||
diff --git a/main.go b/main.go
|
|
||||||
index c1b3786..ef0beae 100644
|
|
||||||
--- a/main.go
|
|
||||||
+++ b/main.go
|
|
||||||
@@ -100,6 +100,7 @@ var modules = map[string]func(*powerline) []pwl.Segment{
|
|
||||||
"rvm": segmentRvm,
|
|
||||||
"shell-var": segmentShellVar,
|
|
||||||
"shenv": segmentShEnv,
|
|
||||||
+ "shlvl": segmentShlvl,
|
|
||||||
"ssh": segmentSSH,
|
|
||||||
"termtitle": segmentTermTitle,
|
|
||||||
"terraform-workspace": segmentTerraformWorkspace,
|
|
||||||
diff --git a/segment-shlvl.go b/segment-shlvl.go
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000..675fa12
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/segment-shlvl.go
|
|
||||||
@@ -0,0 +1,23 @@
|
|
||||||
+package main
|
|
||||||
+
|
|
||||||
+import (
|
|
||||||
+ pwl "github.com/justjanne/powerline-go/powerline"
|
|
||||||
+ "os"
|
|
||||||
+ "strconv"
|
|
||||||
+)
|
|
||||||
+
|
|
||||||
+func segmentShlvl(p *powerline) []pwl.Segment {
|
|
||||||
+
|
|
||||||
+ level, _ := os.LookupEnv("SHLVL")
|
|
||||||
+ leveli, err := strconv.Atoi(level)
|
|
||||||
+
|
|
||||||
+ if err != nil || leveli < 1 {
|
|
||||||
+ return []pwl.Segment{}
|
|
||||||
+ }
|
|
||||||
+ return []pwl.Segment{{
|
|
||||||
+ Name: "shlvl",
|
|
||||||
+ Content: level,
|
|
||||||
+ Foreground: p.theme.ShLvlFg,
|
|
||||||
+ Background: p.theme.ShLvlBg,
|
|
||||||
+ }}
|
|
||||||
+}
|
|
||||||
diff --git a/themes.go b/themes.go
|
|
||||||
index f52c989..2ac1dde 100644
|
|
||||||
--- a/themes.go
|
|
||||||
+++ b/themes.go
|
|
||||||
@@ -139,6 +139,9 @@ type Theme struct {
|
|
||||||
ShEnvFg uint8
|
|
||||||
ShEnvBg uint8
|
|
||||||
|
|
||||||
+ ShLvlFg uint8
|
|
||||||
+ ShLvlBg uint8
|
|
||||||
+
|
|
||||||
NodeFg uint8
|
|
||||||
NodeBg uint8
|
|
||||||
NodeVersionFg uint8
|
|
||||||
diff --git a/themes/default.json b/themes/default.json
|
|
||||||
index f734707..c658f58 100644
|
|
||||||
--- a/themes/default.json
|
|
||||||
+++ b/themes/default.json
|
|
||||||
@@ -63,6 +63,8 @@
|
|
||||||
"ShellVarBg": 11,
|
|
||||||
"ShEnvFg": 15,
|
|
||||||
"ShEnvBg": 130,
|
|
||||||
+ "ShLvlFg": 231,
|
|
||||||
+ "ShLvlBg": 55,
|
|
||||||
"NodeFg": 15,
|
|
||||||
"NodeBg": 40,
|
|
||||||
"NodeVersionFg": 40,
|
|
||||||
--
|
|
||||||
2.33.1
|
|
||||||
|
|
|
@ -118,10 +118,6 @@ with lib;
|
||||||
"update.showReleaseNotes" = false;
|
"update.showReleaseNotes" = false;
|
||||||
"window.menuBarVisibility" = "hidden";
|
"window.menuBarVisibility" = "hidden";
|
||||||
"workbench.startupEditor" = "none";
|
"workbench.startupEditor" = "none";
|
||||||
"terminal.integrated.profiles.linux"."bash" = {
|
|
||||||
"path" = "bash";
|
|
||||||
"args" = [ "-c" "unset SHLVL; bash" ];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.etc."vscode-keybindings.json".text = builtins.toJSON [
|
environment.etc."vscode-keybindings.json".text = builtins.toJSON [
|
||||||
|
|
Loading…
Reference in a new issue