Last active
August 29, 2015 14:23
-
-
Save ad-m/adb9e2708c4731226b6a to your computer and use it in GitHub Desktop.
My bashrc file
This file contains hidden or 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
| source /etc/skel/.bashrc; | |
| function extract(){ atool -x "$@";}; | |
| export WORKON_HOME=$HOME/.virtualenvs | |
| export PROJECT_HOME=$HOME/Devel | |
| source /usr/local/bin/virtualenvwrapper.sh | |
| alias pbcopy='xsel --clipboard --input' | |
| alias pbcopy_clean='tee >(xsel --clipboard --input)' | |
| alias pbcopy='xsel --clipboard --input' | |
| alias pbpaste='xsel --clipboard --output' | |
| # PDF tools | |
| function pdf_count(){ | |
| for i in "$@"; do | |
| pdfinfo "$i"; | |
| done | grep 'Pages' | awk '{ SUM+=$2; }; END{ print SUM; };'; | |
| }; | |
| function pdf_split(){ | |
| for file in "$@"; do | |
| shopt -s nocasematch | |
| if ! [[ "$file" == *.pdf ]]; then | |
| echo "Skip $file X because it's not PDF file"; | |
| continue | |
| fi; | |
| shopt -u nocasematch | |
| pages=$(pdf_count $file); | |
| echo "Detect $pages pages in $file"; | |
| filename="${file%.*}"; | |
| unset Outfile; | |
| for i in $(seq 1 "$pages"); do | |
| pdftk "$file" cat "$i" output "$filename-$i.pdf"; | |
| Outfile[$i]="$filename-$i.pdf"; | |
| done; | |
| done; | |
| }; | |
| function archive_up_priv { | |
| pass=$(~/.config/archive_up_pass.sh); | |
| upload_path="private_html/$(date +'%Y_%m')_$pass" | |
| for file in "$@"; do | |
| s3cmd sync "$file" "s3://cdn.files.jawne.info.pl/$upload_path/" --guess-mime-type -P 1>&2; | |
| done; | |
| wget 'http://files.jawne.info.pl/refresh.php' -qO/dev/null; | |
| echo -n "http://files.jawne.info.pl/$upload_path" | pbcopy_clean; | |
| }; | |
| function archive_up_public { | |
| upload_path="public_html/$(date +'%Y/%m/%d_%X')" | |
| for file in "$@"; do | |
| s3cmd sync "$file" "s3://cdn.files.jawne.info.pl/$upload_path/" --guess-mime-type -P 1>&2; | |
| done; | |
| wget 'http://files.jawne.info.pl/refresh.php' -qO/dev/null; | |
| echo -n "http://files.jawne.info.pl/$upload_path" | pbcopy_clean; | |
| }; | |
| function pdf_redact(){ | |
| for file in "$@"; do | |
| if ! [[ "$file" == *.pdf ]]; then | |
| : else | |
| echo "Skip $file Y because it's not PDF file"; | |
| continue | |
| fi; | |
| pages=$(pdf_count "$file"); | |
| echo "Detect $pages in $file"; | |
| filename="${file%.*}"; | |
| unset Outfile; | |
| for i in $(seq 1 "$pages"); do | |
| pdftk "$file" cat "$i" output "$filename-$i.pdf"; | |
| Outfile[$i]="$filename-$i.pdf"; | |
| done; | |
| gimp "${Outfile[@]}"; | |
| pdftk "${Outfile[@]}" cat output "$filename-anon.pdf"; | |
| rm "${Outfile[@]}"; | |
| read -p "Do you want open output file? " -n 1 -r | |
| echo | |
| if [[ $REPLY =~ ^[Yy]$ ]] | |
| then | |
| evince "$filename-anon.pdf"; | |
| fi | |
| read -p "Do you want upload output file to Archive as public? " -n 1 -r | |
| echo # (optional) move to a new line | |
| if [[ $REPLY =~ ^[Yy]$ ]] | |
| then | |
| archive_up_public "$filename-anon.pdf"; | |
| else | |
| read -p "Do you want upload output file to Archive as private? " -n 1 -r | |
| echo # (optional) move to a new line | |
| if [[ $REPLY =~ ^[Yy]$ ]] | |
| then | |
| archive_up_priv "$filename-anon.pdf"; | |
| fi | |
| fi | |
| done; | |
| }; | |
| function mkcd | |
| { | |
| dir="$*"; | |
| mkdir -p "$dir" && cd "$dir"; | |
| } | |
| function clean_name { | |
| for file in "$@"; do | |
| #echo "$file"; | |
| path=`dirname "$file"`; | |
| filename=`basename "$file"`; | |
| new_name=`echo "$filename" | tr -cd 'a-zA-Z0-9.-_ '` | |
| new_path="$path/$new_name"; | |
| # echo -e " file=$file \n path=$path \n new_path=$new_path\n" | |
| if [ "$filename" != "$new_name" ]; then | |
| echo "$file ==> $new_path"; | |
| mv "$file" "$new_path"; | |
| else | |
| echo "$file skip"; | |
| fi; | |
| done; | |
| }; | |
| function clean_up_django_templates { | |
| find $@ -name '*.html' -exec sed -i -E 's/\{\{([^ ](.+?)[^ ])\}\}/{{ \1 }}/g' "{}" \;; | |
| find $@ -name '*.html' -exec sed -i -E 's/\{%([^ ](.+?)[^ ])%\}/{% \1 %}/g' "{}" \;; | |
| }; | |
| alias random_pass="(strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 15 | tr -d '\n'; echo)"; | |
| # Add number to end name of files eg. add_number baba.pdf brzoza.pdf -> mv baba{,-1}.pdf; mv brzoza{,-2}.pdf; | |
| function add_number(){ | |
| i=1; | |
| for file in "$@"; do | |
| echo mv \"$file\" \"$i""_""$file\"\;; ((i++)); | |
| done; | |
| } | |
| function revdns () | |
| { | |
| for host in "$@"; | |
| do | |
| dig +noall +answer "$host"; | |
| for ip in $(dig +short $host); | |
| do | |
| dig +noall +answer -x "$ip"; | |
| done; | |
| done | |
| } | |
| alias chmod='chmod -v' | |
| function chunk(){ | |
| url=$(cat - |curl -T - chunk.io 2>/dev/null); | |
| echo -n "$url" | pbcopy; | |
| echo "$url"; | |
| }; | |
| ### Added by the Heroku Toolbelt | |
| export PATH="/usr/local/heroku/bin:$PATH" | |
| alias fuck='sudo $(history -p \!\!)' | |
| function l10n(){ | |
| if [ -e manage.py ] ; then | |
| FILE="manage.py"; | |
| elif [ -e ../manage.py ] ; then | |
| FILE="../manage.py"; | |
| elif [ -e ../../manage.py ] ; then | |
| FILE="../../manage.py"; | |
| fi | |
| $FILE makemessages -l pl && poedit locale/pl/LC_MESSAGES/django.po && $FILE compilemessages -l pl; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment