Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

89 wiersze
1.9 KiB

  1. #!/usr/bin/env perl
  2. use strict;
  3. use warnings;
  4. my $tmux_command = "tmux";
  5. my @tmux_set_command = ("set", "-g");
  6. my @tmux_setw_command = ("setw", "-g");
  7. my %color_prefs = (
  8. "arch-aspireone" => "blue,white",
  9. "darwin-mba.local" => "yellow,black",
  10. "newkiwi" => "magenta,white"
  11. );
  12. my $color_def = "green,white";
  13. sub tmux {
  14. my @command = ($tmux_command, );
  15. push(@command, @_);
  16. # print "@command, \n";
  17. system(@command) == 0
  18. or die "system @command failed: $?";
  19. }
  20. sub set {
  21. my @command = @tmux_set_command;
  22. push(@command, @_);
  23. tmux(@command);
  24. }
  25. sub setw {
  26. my @command = @tmux_setw_command;
  27. push(@command, @_);
  28. tmux(@command);
  29. }
  30. sub set_key {
  31. tmux("unbind", "C-b");
  32. set("prefix", "C-z");
  33. tmux("bind-key", "C-z", "send-prefix");
  34. tmux("bind-key", "c", "command-prompt", "new-window '%%'");
  35. }
  36. sub set_prefs {
  37. setw("mode-keys", "vi");
  38. set("default-command", "/bin/bash");
  39. set("default-path", $ENV{"HOME"});
  40. set("set-titles", "on");
  41. set("display-panes-time", "5000");
  42. }
  43. sub set_status_line {
  44. my $user = $ENV{"USER"};
  45. my $hostname = $ENV{"HOSTNAME"};
  46. my $tmux_v = `tmux -V`;
  47. $tmux_v =~ s/\n//;
  48. set("status-right", "${user}\@${hostname} | ${tmux_v} ");
  49. }
  50. sub set_colors {
  51. my $hostname = $ENV{"HOSTNAME"};
  52. my $color = $color_prefs{$hostname};
  53. if (! $color) {
  54. $color = $color_def;
  55. }
  56. my ($bg, $fg) = split(/,/, $color);
  57. set("status-bg", $bg);
  58. set("status-fg", $fg);
  59. set("mode-bg", $bg);
  60. set("mode-fg", $fg);
  61. set("pane-active-border-fg", $bg);
  62. set("message-bg", "white");
  63. set("message-fg", "black");
  64. setw("window-status-current-bg", "white");
  65. setw("window-status-current-fg", "black");
  66. setw("window-status-current-attr", "bold");
  67. }
  68. sub main {
  69. set_key();
  70. set_prefs();
  71. set_status_line();
  72. set_colors();
  73. }
  74. main();