Advertisement
Guest User

Fix for tmux error "failed to connect to server: No error"

a guest
May 31st, 2014
1,088
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.66 KB | None | 0 0
  1. #!/usr/bin/env perl
  2.  
  3. # Fix for tmux error "failed to connect to server: No error" on 64-bit Cygwin caused by tmux not deleting its temporary directory upon exit
  4. # Reference: http://superuser.com/questions/760503/cygwin-tmux-failed-to-connect-to-server-no-error
  5.  
  6. # check if tmux is running
  7. my $running = `ps |grep tmux 2>/dev/null`;
  8.  
  9. # check if tmux has any temporary directories
  10. chomp(my @tmux_tmp = `ls /tmp |grep tmux`);
  11.  
  12. # if it isn't running and there are temp directories, remove them
  13. if (! $running && @tmux_tmp) {
  14.   system "rm -rf /tmp/$_" for @tmux_tmp;
  15. }
  16.  
  17. # run the desired tmux command
  18. my $c = "/usr/bin/tmux";
  19. $c .= " '$_'" for @ARGV;
  20. exec $c;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement