Skip to content

Instantly share code, notes, and snippets.

@z448
Last active March 24, 2016 19:14
Show Gist options
  • Save z448/d72d77d1cfc6687fdaad to your computer and use it in GitHub Desktop.
Save z448/d72d77d1cfc6687fdaad to your computer and use it in GitHub Desktop.
shells
#!/bin/bash
# term line bash4>
printf "%`tput cols`s"|tr ' ' '-'
#!/bin/bash
# make list of available packages and filter out with search
# to list all p5 libs (~2000) on cydia coredevs.nl repo
apt-cache search p5- | cut -d' ' -f1 > p5-list
# check list, remove what you dont need
# this will assume 'Yes' instead of prompting after every package
for i in `cat p5-list`;do apt-get assume-yes install $i; sleep 3; done
#!/bin/bash
echo -ne "packaging: ";echo -ne "\e[10m deb ";sleep 2; echo -ne "\b\b\b\b ";echo -ne "\b\b\b\b\e[7m par \e[0m"; sleep 1;echo -e "\e-C"
#!/bin/bash
# In bash, declare -p can be used to dump the definition of a variable as shell code ready to be interpreted, so you can do updates to the file with:
file=${1?}; shift
declare -A row
source -- "$file" || exit
while [ "$#" -ge 2 ]; do
row[$1]=$2
shift 2
done
declare -p row > "$file"
A script to show the contents of the file would be:
#! /bin/bash -
file=${1?}; shift
declare -A row
source -- "$file"
for i in "${!row[@]}"
do
echo "key : $i"
echo "value: ${row[$i]}"
done
# <copy paste into terminal>
# prompt for gist username and prints URLs to public gists
perl -e '
print "add user and <Enter> and <Ctrl-D>:";
$url=q|https://gist.github.com|;
while(<>){ $g = $url . q|/| . $_ }; open( my $GS,"-|","curl -#sL $g");
while(<$GS>){
if( m|tr.+ate| ){
s/(.*?)(\=\")(.*?)(\".*?\>)(.*?\>)(.*?)(\<.*)/$3$6/;
$gist->{$6} = $3;
}};
for(keys %$gist){ print $_ . " -\> " . $url . $gist->{$_} . "\n" };
'
#!/bin/bash
######################################################################################################
## function to find out your current terminal width
## source it or put into .bashrc then $_ttyw has terminal width and _line prints line trough terminal
## :~$ echo $_ttyw
## 143
## :~$ _line
##_____________________________________________________________________________________________________
function _ttyw {
colu=0
for i in `stty -a | head -1`
do
colu=$(($colu+1))
if [ $i == 'columns;' ]
then
colu=$(($colu - 1))
fi
done
_ttyw=$(stty -a | head -1 | cut -d' ' -f$colu)
export _ttyw
}
function _line {
_ttyw
v=$(printf "%-${_ttyw}s" "_")
echo "${v// /_}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment