Last active
August 4, 2016 06:04
-
-
Save dolik-rce/9819bd5ed20894984421c763dd4c2ebe to your computer and use it in GitHub Desktop.
Pár vychytávek z mého .bashrc
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
# Malá pythoní kalkulačka, | |
# stačí napsat výraz a zmáčkount Ctrl+E | |
bind -x "\"\\C-e\": python <<< \" | |
from __future__ import print_function | |
from math import * | |
from re import match, split | |
s = '\${READLINE_LINE//\"'\"/\"\\\\'\"}' | |
for x in split('[;\n]\s*', s): | |
try: | |
print('%s\033[32m' % x) | |
r = eval(x) | |
print('\033[33m = %s' % str(r)) | |
except: | |
exec(x) | |
m = match('\s*([\w])\s*=', x) | |
if m: | |
print('\033[33m = %s' % str(eval(m.group(1)))) | |
finally: | |
print('\033[0m', end='') | |
\"" | |
# Zkratka pro spočítání výskytů řádku v souboru nebo streamu | |
function us { | |
sort "$@" | uniq -c | sort -h | |
} | |
# Přetížení cat aby podporovalo vypsalo "obsah" i pokud mu předáme adresář | |
function cat { | |
[ -d "$1" ] && ls $@ || $(type -fp cat) $@ | |
} | |
# Aliasy na časté překlepy gitu, včetně napovídání | |
alias gti='git' | |
alias gi='git' | |
alias g='git' | |
complete -o default -o nospace -F _git gti | |
complete -o default -o nospace -F _git gi | |
complete -o default -o nospace -F _git g | |
# POZOR: na ArchLinuxu je potřeba nastavit compltion trochu jinak: | |
# . /usr/share/bash-completion/completions/git | |
# __git_complete gti __git_main | |
# __git_complete gi __git_main | |
# __git_complete g __git_main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment