center date

This commit is contained in:
Ingolf Wagner 2019-12-31 21:56:47 +13:00
parent 9aec67c1db
commit c23d7182f1
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
2 changed files with 13 additions and 19 deletions

View file

@ -6,7 +6,7 @@
let
hrule = ''${pkgs.terminal-tools}/bin/hrule'';
hrule = "${pkgs.terminal-tools}/bin/hrule";
q-cal = let
@ -78,34 +78,27 @@ let
'
'';
q-timeZoneDate = zone:
q-timeZoneDate = size: zone:
let
dateString = comment:
"'+%Y-%m-%dT[;38;5;${
toString timeColor
}m%H:%M:%S[;38;5;${toString timeZoneColor}m%:z ${comment}' ";
timeZoneVariable = lib.optionalString (zone != null) "TZ=${zone}";
comment = lib.optionalString (zone != null) " : ${zone}";
comment = lib.optionalString (zone != null)
" : ${lib.fixedWidthString size " " zone}";
# sh
in ''
${timeZoneVariable} ${pkgs.coreutils}/bin/date ${dateString comment}
${timeZoneVariable} ${pkgs.coreutils}/bin/date ${
dateString comment
} | ${pkgs.terminal-tools}/bin/center
'';
q-timeZoneDates = if timeZones == [ ] then
q-timeZoneDate null
q-timeZoneDate 0 null
else
lib.concatMapStringsSep "\n" q-timeZoneDate timeZones;
q-gitdir = ''
if test -d .git; then
#git status --porcelain
branch=$(
${pkgs.git}/bin/git branch \
| ${pkgs.gnused}/bin/sed -rn 's/^\* (.*)/\1/p'
)
echo "± $LOGNAME@''${HOSTNAME-$(${pkgs.nettools}/bin/hostname)}:$PWD .git $branch"
fi
'';
let size = lib.foldr lib.max 0 (map builtins.stringLength timeZones);
in lib.concatMapStringsSep "\n" (q-timeZoneDate size) timeZones;
q-intel_backlight = ''
cd /sys/class/backlight/intel_backlight

View file

@ -7,8 +7,9 @@ rustPlatform.buildRustPackage rec {
#src = ./.;
src = fetchgit {
url = "https://git.ingolf-wagner.de/palo/terminal-tools";
rev = "e77560d04aa6b86da2a8dc235c7168ca9cdd7d45";
sha256 = "087cp0m42x3rjkkhh3zi48ahz4qkavr7lgc9fy299m9gjy6alb7p";
rev = "816cfd8eae8f8136437e4076116e0267c6a6eb0d";
sha256 = "07zf716wy0rqpzwj580haw935lj5ih0wzhfn26dq83kf9nm09iyg";
};
cargoSha256 = "0dgbw6idlzzpgljv0lxavimh1h8qlib0qrcn92f5imy6a12phrmm";