App-sshwrap-hostcolor

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

0.009   2019-07-26  Released-By: PERLANCAR; Urgency: medium

	- [ux] Disable feature that change terminal background color during
	  completion because it currently changes background color
	  permanently; we want temporary change just for preview.


0.008   2019-03-12  Released-By: PERLANCAR

	- [Bugfix] [regression] Re-add removed function read_history_file()
	  because it is used by completer script.


0.007   2019-03-12  Released-By: PERLANCAR

Changes  view on Meta::CPAN


	- No functional changes.

	- [doc] Add some YouTube video demonstration links.

	- [doc] Mention SSHWRAP_HOSTCOLOR_AUTO in Synopsis.


0.003   2018-09-26  Released-By: PERLANCAR

	- [Bugfix] Fix completion to set terminal background color.


0.002   2018-09-26  Released-By: PERLANCAR

	- Observe SSHWRAP_HOSTCOLOR_AUTO.


0.001   2018-09-25  Released-By: PERLANCAR

        - First release.

META.json  view on Meta::CPAN

{
   "abstract" : "SSH wrapper script to remember the terminal background you use for each host",
   "author" : [
      "perlancar <perlancar@cpan.org>"
   ],
   "dynamic_config" : 0,
   "generated_by" : "Dist::Zilla version 6.012, CPAN::Meta::Converter version 2.150010",
   "license" : [
      "perl_5"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",

META.yml  view on Meta::CPAN

---
abstract: 'SSH wrapper script to remember the terminal background you use for each host'
author:
  - 'perlancar <perlancar@cpan.org>'
build_requires:
  File::Spec: '0'
  IO::Handle: '0'
  IPC::Open3: '0'
  Test::More: '0'
configure_requires:
  ExtUtils::MakeMaker: '0'
dynamic_config: 0

Makefile.PL  view on Meta::CPAN

# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.012.
use strict;
use warnings;

use 5.010001;

use ExtUtils::MakeMaker;

my %WriteMakefileArgs = (
  "ABSTRACT" => "SSH wrapper script to remember the terminal background you use for each host",
  "AUTHOR" => "perlancar <perlancar\@cpan.org>",
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => 0
  },
  "DISTNAME" => "App-sshwrap-hostcolor",
  "EXE_FILES" => [
    "script/_sshwrap-hostcolor",
    "script/sshwrap-hostcolor"
  ],
  "LICENSE" => "perl",

README  view on Meta::CPAN

NAME
    App::sshwrap::hostcolor - SSH wrapper script to remember the terminal
    background you use for each host

VERSION
    This document describes version 0.009 of App::sshwrap::hostcolor (from
    Perl distribution App-sshwrap-hostcolor), released on 2019-07-26.

SYNOPSIS
    See the included script sshwrap-hostcolor.

HOMEPAGE
    Please visit the project's homepage at

lib/App/sshwrap/hostcolor.pm  view on Meta::CPAN

        log_trace "Adding entry for '%s' in history file: %s", $key, $val;
        push @lines, "$key\t$val\n";
    }

    seek $fh, 0, 0;
    print $fh @lines;
    truncate $fh, tell($fh);
}

1;
# ABSTRACT: SSH wrapper script to remember the terminal background you use for each host

__END__

=pod

=encoding UTF-8

=head1 NAME

App::sshwrap::hostcolor - SSH wrapper script to remember the terminal background you use for each host

=head1 VERSION

This document describes version 0.009 of App::sshwrap::hostcolor (from Perl distribution App-sshwrap-hostcolor), released on 2019-07-26.

=head1 SYNOPSIS

See the included script L<sshwrap-hostcolor>.

=for Pod::Coverage ^(.+)$

script/_sshwrap-hostcolor  view on Meta::CPAN

        my %args = @_;
        if ($args{argpos} == 0) {
            # lookup user@host from history file
            my $history = App::sshwrap::hostcolor::read_history_file();
            my $ans = Complete::Util::complete_array_elem(
                array => [keys %$history], word => $args{word});
            if ($ans && ref($ans) eq 'ARRAY') {
                if (!@$ans) {
                    return undef;
                } elsif (@$ans == 1 && $history->{$ans->[0]}) {
                    # currently commented because it changes background color
                    # permanently, even after sshwrap executes and exits. this
                    # should be changed to: launching a background process that
                    # sets terminal color for a couple of seconds just for demo,
                    # then change back to original color.

                    #require XTerm::Util;
                    #log_trace "Setting background color for $ans->[0] ($history->{$ans->[0]}) ...";
                    #XTerm::Util::set_term_bgcolor($history->{$ans->[0]}, 1);
                }
            }
            $ans;
        } else {
            return undef;
        }
    }
};

script/sshwrap-hostcolor  view on Meta::CPAN

### main

log_info "start";
init;
set_hostcolor;
run_ssh;
get_hostcolor;
log_info "end";
exit $exitcode;

# ABSTRACT: SSH wrapper script to remember the terminal background you use for each host
# PODNAME: sshwrap-hostcolor

__END__

=pod

=encoding UTF-8

=head1 NAME

sshwrap-hostcolor - SSH wrapper script to remember the terminal background you use for each host

=head1 VERSION

This document describes version 0.009 of sshwrap-hostcolor (from Perl distribution App-sshwrap-hostcolor), released on 2019-07-26.

=head1 SYNOPSIS

Use like you would B<ssh>:

 % sshwrap-hostcolor -v ujang@host1.example

For convenience, alias this script to B<ssh>. In your Unix shell:

 alias ssh=sshwrap-hostcolor

then you can use it like this:

 % ssh -v ujang@host1.example

After you ssh to the remote host, change the background color of your terminal
(e.g. to dark blue). Upon exit, the script will retrieve the terminal's current
background color and record this line to F<~/.sshwrap-hostcolor.history>:

 ujang@host1.example     00002b

Next time you ssh to the same C<user@host> combination, the script will set the
terminal's background color to dark blue.

As a bonus, you can also activate the completion script L<_sshwrap-hostcolor>:

 complete -C _sshwrap-hostcolor ssh

this will let you complete C<user@host> and immediately change the background
color to the remembered one.

And as another bonus, if you set C<SSHWRAP_HOSTCOLOR_AUTO> to C<random-dark> (or
C<random-light>), the script will automatically assign a random color for each
unrecognized user+host.

=head1 DESCRIPTION

=head1 FAQ

=head2 The script doesn't work!

To get and set terminal background color programmatically, an xterm-compatible
terminal is required. Please see the list here: L<XTerm::Util>.

=head1 ENVIRONMENT

=head2 SSHWRAP_HOSTCOLOR_AUTO

String. Can be set to C<random-dark> to automatically set the color of a new
user+host with a random color between "000000" and "3f3f3f". Can be set
toC<random-light> to automatically set the color of a new user+host with a
random color between "c0c0c0" and "ffffff".



( run in 2.223 seconds using v1.01-cache-2.11-cpan-f56aa216473 )