Last active
June 1, 2023 16:05
-
-
Save gonter/3599bf44428b9f126db4 to your computer and use it in GitHub Desktop.
dotfiles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias ..="tcsh -l" | |
alias sux="sudo tcsh -l" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .bash_profile | |
# Get the aliases and functions | |
if [ -f ~/.bashrc ]; then | |
. ~/.bashrc | |
fi | |
if [ -f ~/.bashrc.local ]; then | |
. ~/.bashrc.local | |
fi | |
# User specific environment and startup programs | |
PATH=$PATH:$HOME/bin | |
export PATH | |
export PATH="$HOME/.cargo/bin:$PATH" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .bashrc | |
# Source global definitions | |
if [ -f /etc/bashrc ]; then | |
. /etc/bashrc | |
fi | |
# User specific aliases and functions | |
# remove annoying global aliases | |
noalias() { | |
x=`type $1 2>&1 | grep " is aliased to "` && unalias $1 | |
} | |
# unalias l. ll ls vi | |
noalias l. | |
noalias ll | |
noalias ls | |
noalias vi | |
noalias egrep | |
noalias fgrep | |
noalias grep | |
alias ..="tcsh -l" | |
alias sux="sudo tcsh -l" | |
# Alias definitions. | |
# You may want to put all your additions into a separate file like | |
# ~/.bash_aliases, instead of adding them here directly. | |
# See /usr/share/doc/bash-doc/examples in the bash-doc package. | |
if [ -f ~/.bash_aliases ]; then | |
. ~/.bash_aliases | |
fi | |
set -P |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias .. source ~/.login | |
set prompt='csh %m:%n> ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set prompt='%m:%n> ' | |
setenv PERL5LIB "$HOME/perl:/usr/local/lib/perl5" | |
setenv SHELL $shell | |
set path=($HOME/bin $path) | |
alias sux sudo tcsh -l | |
alias S SLS -P | |
alias tsv ~/bin/csv --UTF8 --TAB | |
setenv EDITOR `which vi` | |
setenv LC_ALL en_US.UTF-8 | |
setenv LESSCHARSET utf-8 | |
setenv PYTHONSTARTUP ~/.pythonrc | |
alias cal ncal -wbM | |
if (-x ~/.login.local) then | |
source ~/.login.local | |
endif | |
if (-x ~/.cargo/cenv) then | |
source ~/.cargo/cenv | |
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.pythonrc | |
# enable syntax completion | |
try: | |
import readline | |
except ImportError: | |
print("Module readline not available.") | |
else: | |
import rlcompleter | |
readline.parse_and_bind("tab: complete") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# turn Red Hat's annoying missfeature off | |
hardstatus off | |
utf8 on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" turn off rainbow effect [ http://www.howtogeek.com/howto/linux/disable-syntax-highlighting-in-vim/ ] | |
syntax off | |
set ai | |
set copyindent | |
set ts=2 | |
set number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
sysctl -a net.ipv6.conf 2>/dev/null | awk '/disable_ipv6/ { print $1"=1"}' | xargs sysctl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
sysctl -a net.ipv6.conf 2>/dev/null | awk '/disable_ipv6/ { print $1"=0"}' | xargs sysctl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
sysctl -a net.ipv6.conf 2>/dev/null | awk '/disable_ipv6/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
=head1 NAME | |
show_fingerprints.pl | |
=head1 DESCRIPTION | |
display fingerprints of all public keys and keys in authorized_keys | |
=cut | |
use strict; | |
my ($version, $has_E)= get_ssh_version(); | |
my $hash_algorithm= 'MD5'; | |
my @files= <*.pub>; | |
while (my $arg= shift (@ARGV)) | |
{ | |
if ($arg eq '--') {} | |
elsif ($arg =~ m#^--(.+)#) | |
{ | |
} | |
elsif ($arg =~ m#^-(.+)#) | |
{ | |
# print ">>> arg=[$arg] 1=[$1]\n"; | |
my @opts= split ('', $1); | |
foreach my $opt (@opts) | |
{ | |
if ($opt eq 'E') | |
{ | |
$has_E= 1; | |
$hash_algorithm= shift (@ARGV); | |
# print "NOTE: hash_algorithm=[$hash_algorithm]\n"; | |
} | |
} | |
} | |
else | |
{ | |
push (@files, $arg); | |
} | |
} | |
# print "files: ", join (' ', @files), "\n"; | |
push (@files, <authorized_keys*>); | |
printf ("%-24s %5s %-51s %-7s %s\n", qw(file size fingerprint type notes)); | |
foreach my $file (@files) | |
{ | |
my @cmd= qw(ssh-keygen -l); | |
push (@cmd, '-E', $hash_algorithm) if ($has_E); | |
push (@cmd, '-f', $file); | |
# print "cmd: [", join (' ', @cmd), "\n"; | |
my $res= `@cmd`; | |
my @lines= split ("\n", $res); | |
foreach my $line (@lines) | |
{ | |
my ($size, $fp, $notes)= split (' ', $line, 3); | |
my $type= 'unknown'; | |
if ($notes =~ m#(.+)\s+\((.+)\)#) { ($notes, $type)= ($1, $2) } | |
$fp= join(':', $hash_algorithm, $fp) unless ($has_E); | |
printf ("%-24s %5d %-51s %-7s %s\n", $file, $size, $fp, $type, $notes); | |
} | |
} | |
sub get_ssh_version | |
{ | |
# my @cmd= qw(ssh-keygen --version); # apparently, there is way to display the version directly | |
my @cmd= qw(ssh-keygen -?); # apparently, --version does not fail as expected on some systems, e.g. openssh-5.3p1-118.1.el6_8.x86_64 | |
# print "cmd: ", join (' ', @cmd), "\n"; | |
my $res= `@cmd 2>&1`; | |
# print "res=[$res]\n"; | |
my $version= 'unknown'; | |
my $has_E= 0; | |
foreach my $l (split ("\n", $res)) | |
{ | |
# print "[$l]\n"; | |
if ($l =~ ' -L Print the contents of a certificate.') { $has_E= 0; } | |
elsif ($l eq ' ssh-keygen -l [-v] [-E fingerprint_hash] [-f input_keyfile]') { $has_E= 1; } | |
} | |
if ($version eq 'unknown') | |
{ | |
my @cmd2= qw(ssh -V); # let's try this ... | |
my $res2= `@cmd2 2>&1`; | |
print "res2=[$res2]\n"; | |
# TODO: figure out how to match that ... | |
} | |
($version, $has_E); | |
} | |
=head1 COMPATIBILITY | |
=head2 Ubuntu | |
* openssh-client 1:7.2p2-4ubuntu2.1 | |
=head2 CentOS | |
* openssh-5.3p1-118.1.el6_8.x86_64 | |
=head1 TODO | |
optionally display fingerprints using other hashing algorithms | |
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# | |
# find or create screen session | |
# | |
# $Id: SLS,v 1.4 2022/04/15 15:46:06 gonter Exp $ | |
# | |
=pod | |
=head1 USAGE | |
SLS [-opts] [session] | |
=head1 DESCRIPTION | |
reattach or create screen which matches given session name | |
=head1 SYNOPSIS | |
SLS mistkisten | |
... reattaches or creates a screen called "mistkisten" | |
SLS mistk | |
... reattaches the screen called "mistkisten" which was created earlier (or otherwise it creates a screen called "mistk") | |
=head1 Options | |
-P ... supress process listin | |
-n ... do not actually perform screen command | |
-c ... create new session even if one matches | |
-t ... print entire process tree for a given screen session | |
=cut | |
use strict; | |
use Data::Dumper; | |
$Data::Dumper::Indent= 1; | |
my $print_tree= 0; # 0 print only last command; 1 print all commands in the tree | |
my $create= 0; | |
my $doit= 1; | |
my $list_processes= 1; | |
my $debug= 0; | |
my @PARS= (); | |
PARS: while (defined (my $arg= shift (@ARGV))) | |
{ | |
if ($arg =~ /^-/) | |
{ | |
if ($arg eq '--') { push (@PARS, @ARGV); last PARS; } | |
elsif ($arg eq '-c') { $create= 1; } | |
elsif ($arg eq '-n') { $doit= 0; } | |
elsif ($arg eq '-P') { $list_processes= 0; } | |
elsif ($arg eq '-t') { $print_tree= 1; } | |
elsif ($arg =~ /^-(D+)/) { $debug += length ($1); } | |
else { &usage (); exit (0); } | |
} | |
else | |
{ | |
push (@PARS, $arg); | |
} | |
} | |
my $S= &screen_ls (); | |
## print Dumper ($S); | |
my $hostname= &get_hostname (); | |
if (@PARS) | |
{ | |
my $wanted= shift (@PARS); | |
my $dir_changed= 0; | |
my @screens= &find_screens_by_label ($S, $wanted); | |
my $cnt= @screens; | |
print "create=$create cnt=$cnt screens=", join ('|', @screens), "\n"; | |
if ($create || $cnt == 0) | |
{ # no matching screen or force creation | |
if (@PARS) | |
{ | |
my $cdir= shift (@PARS); | |
&chdir ($cdir); | |
$dir_changed= 1; | |
} | |
my $cmd_title= "settitle '$hostname:$wanted'"; | |
print ">>> $cmd_title\n"; | |
system ($cmd_title) if ($doit); | |
my @cmd_screen= ('screen', '-S', $wanted); | |
my $rc_wanted= ".screenrc-$wanted"; | |
push (@cmd_screen, '-c', $rc_wanted) if (-f $rc_wanted); | |
print ">>> ", join(' ', @cmd_screen), "\n"; | |
if ($doit) | |
{ | |
if (!$dir_changed && $wanted =~ /notes/i) { &chdir ("common/Notes"); $dir_changed= 1; } | |
system (@cmd_screen); | |
} | |
} | |
elsif ($cnt == 1) | |
{ | |
$wanted= shift (@screens); | |
my $cmd_title= "settitle '$hostname:$wanted'"; | |
print ">>> $cmd_title\n"; | |
system ($cmd_title) if ($doit); | |
my $cmd_screen= "screen -dR '$wanted'"; | |
print ">>> $cmd_screen\n"; | |
system ($cmd_screen) if ($doit); | |
} | |
else # $cnt > 0: more than one screen found, so give user a chance to be more specific | |
{ | |
my $PS; | |
if ($list_processes) | |
{ | |
$PS= &ps ('alfxww'); | |
## print Dumper ($PS); | |
} | |
&print_screens_by_label2 ($S, $PS, @screens); | |
} | |
} | |
else | |
{ | |
my $PS; | |
if ($list_processes) | |
{ | |
$PS= &ps ('alfx'); | |
## print Dumper ($PS); | |
} | |
&print_screens_by_label ($S, $PS); | |
} | |
exit (0); | |
sub chdir | |
{ | |
my $dir= shift; | |
print ">>> chdir '$dir'\n"; | |
# sleep (5); | |
unless (chdir && chdir $dir) | |
{ | |
print ">>> ATTN: cant change to '$dir' (", $@, ")\n"; | |
sleep (5); | |
} | |
} | |
sub usage | |
{ | |
exec ("perldoc '$0'"); | |
} | |
sub get_hostname | |
{ | |
my $x= $ENV{'BLA'}; | |
unless ($x) | |
{ | |
my ($OS, $y)= split (' ', `uname -a`); | |
$x= $y; | |
} | |
if ($x) | |
{ | |
my @x= split (/\./, $x); | |
my $x= shift (@x); | |
# check if $x may need more info | |
return $x; | |
} | |
} | |
sub find_screens_by_label | |
{ | |
my $S= shift; | |
my $wanted= shift; | |
print ">> matching /$wanted/i\n"; | |
my @res= (); | |
my $Sl= $S->{'labels'}; | |
foreach my $l (sort keys %$Sl) | |
{ | |
print "l=[$l]\n"; | |
if ($l =~ /$wanted/i) | |
{ | |
push (@res, $l) | |
} | |
} | |
@res; | |
} | |
sub print_screens_by_pid | |
{ | |
my $S= shift; | |
my $PS= shift; | |
my $Ss= $S->{'screens'}; | |
foreach my $p (sort {$a <=> $b} keys %$Ss) | |
{ | |
my $x= $Ss->{$p}; | |
my ($pid, $status, $label)= map { $x->{$_} } qw(pid status label); | |
printf ("%7d %s %s\n", $pid, $status, $label); | |
&print_cmd ($PS, $pid, 0); | |
} | |
} | |
sub print_screens_by_label | |
{ | |
my $S= shift; | |
my $PS= shift; | |
&print_screens_by_label2 ($S, $PS, sort keys %{$S->{'labels'}}); | |
} | |
sub print_screens_by_label2 | |
{ | |
my $S= shift; | |
my $PS= shift; | |
my @labels= @_; | |
printf ("%7s %8s %s\n", 'PID', 'Status', 'Label'); | |
my $Sl= $S->{'labels'}; | |
foreach my $l (@labels) | |
{ | |
my $x= $Sl->{$l}; | |
my ($pid, $status, $label)= map { $x->{$_} } qw(pid status label); | |
printf ("%7d %s %s\n", $pid, $status, $label); | |
&print_cmd ($PS, $pid, 0); | |
} | |
} | |
sub print_cmd | |
{ | |
my $PS= shift; | |
my $pid= shift; | |
my $indent= shift; | |
return unless ($PS); | |
## print join (' ', __LINE__, 'pid', $pid, $indent), "\n"; | |
my $p= $PS->{'pids'}->{$pid}; | |
my $c= $PS->{'c'}->{$pid}; | |
if (defined ($p) # note: a process with the screen's pid is not in ps list | |
&& ($print_tree || !defined ($c)) | |
) | |
{ | |
$indent += 2; | |
my $label_idx= $PS->{'label_idx'}; | |
my ($pid, $cmd)= map { $p->[$label_idx->{$_}] } qw(PID COMMAND); | |
printf ("%7d %s %s\n", $pid, ' 'x$indent, $cmd); | |
## print ' 'x$indent, join (' ', @$p), "\n"; | |
} | |
if (defined ($c)) | |
{ | |
## print ' 'x$indent, join (' ', '->', @$c), "\n"; | |
foreach my $cpid (@$c) | |
{ | |
&print_cmd ($PS, $cpid, $indent); | |
} | |
} | |
} | |
sub screen_ls | |
{ | |
local *S; | |
open (S, "screen -ls|") or return undef; | |
my %screens= (); | |
my %labels= (); | |
my $screens= | |
{ | |
'screens' => \%screens, | |
'labels' => \%labels, | |
}; | |
while (<S>) | |
{ | |
chop; | |
print ">>>> $_\n" if ($debug >= 2); | |
if (/^There are screens on:/ | |
|| /^\s*$/ | |
) | |
{ # NOP; | |
} | |
elsif (/^(\d+) Sockets in (.+)/) | |
{ | |
($screens->{'cnt'}, $screens->{'socket_dir'})= ($1, $2); | |
} | |
elsif (/\s+(\d+)\.(.+)\s*\((Attached|Detached)\)/) | |
{ | |
my ($pid, $label, $status)= ($1, $2, $3); | |
my $extra; | |
if ($label =~ /(.+)\s+\((.+)\)/) | |
{ | |
($label, $extra)= ($1, $2); | |
} | |
else | |
{ | |
$label=~ s/\s*$//; | |
} | |
## print ">>>>> pid='$pid' label='$label' status='$status'\n"; | |
my $screen= | |
{ | |
'pid' => $pid, | |
'label' => $label, | |
'status' => $status, | |
}; | |
$screen->{'extra'}= $extra if ($extra); | |
$screens{$pid}= $screen; | |
$labels{$label}= $screen; | |
} | |
} | |
close (S); | |
print Dumper ($screens) if ($debug >= 3); | |
$screens; | |
} | |
sub ps | |
{ | |
my $options= shift || 'alf'; | |
local *PS; | |
open (PS, "ps '$options'|") or die "cant call ps with options='$options'"; | |
my %pids= (); | |
my @labels= (); | |
my %label_idx= (); | |
my %c= (); | |
my $ps= | |
{ | |
'labels' => \@labels, | |
'label_idx' => \%label_idx, | |
'pids' => \%pids, | |
'c' => \%c, | |
}; | |
my $columns= 999; | |
while (<PS>) | |
{ | |
chop; | |
## print ">>> $_\n"; | |
my @f= split (' ', $_, $columns); | |
unless (@labels) | |
{ # first line is the label of the output | |
@labels= @f; | |
for (my $i= 0; $i <= $#labels; $i++) | |
{ | |
$label_idx{$labels[$i]}= $i; | |
$columns= $i+1; | |
} | |
$ps->{'columns'}= $columns; | |
} | |
else | |
{ | |
my ($pid, $ppid)= map { @f[$label_idx{$_}] } qw(PID PPID); | |
## print ">>>>> pid='$pid' ppid='$ppid'\n"; | |
$pids{$pid}= \@f; | |
push (@{$c{$ppid}}, $pid); | |
} | |
} | |
close (PS); | |
$ps; | |
} | |
__END__ | |
=pod | |
[2008-06-25 19:30] | |
=head1 TODO | |
=head2 Config File | |
rk_dir= DIR => CD vor screen -S ausfuehren | |
(what the hell, what does rk_dir mean? chdir?) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment