You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
2.6 KiB

#
# ~/.bashrc
#
8 years ago
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
8 years ago
### Alias ###
8 years ago
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
8 years ago
fi
alias ls='ls --color=auto'
alias ll='ls -alF'
alias la='ls -A'
8 years ago
alias lock='qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock'
alias lock='import -window root /tmp/screenshot.png && convert /tmp/screenshot.png -blur 0x4 /tmp/screenshot.png && i3lock -i /tmp/screenshot.png'
### Prompt ###
8 years ago
# Add git branch if its present to PS1
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
# print time
print_time() {
printf "%*s%s\r" "$(tput cols)" "($(date +%H:%M))"
}
# print cc compilater
print_cc() {
if [ ! -z "${CC}" ]
then
echo ${CC} | awk '{print " ["$1"]";}'
fi
}
# prompt sans heure
PS1='\[\033[00;35m\][${debian_chroot:+($debian_chroot)}\u@\h\[\033[00;35m\]:\[\033[00;36m\]\w\[\033[00;35m\]]\[\033[00;31m\]$(parse_git_branch)\[\033[00;34m\]$(print_cc)\n\[\033[00m\]\$ '
# prompt avec heure
PS1='\[\033[00;33m\]$(print_time)\[\033[00;35m\][${debian_chroot:+($debian_chroot)}\u@\h\[\033[00;35m\]:\[\033[00;36m\]\w\[\033[00;35m\]]\[\033[00;31m\]$(parse_git_branch)\[\033[00;34m\]$(print_cc)\n\[\033[00m\]\$ '
8 years ago
### Completion ###
# Use bash-completion, if available
[[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] && \
. /usr/share/bash-completion/bash_completion
### Variable ###
8 years ago
# For yaourt/pacman
export VISUAL="vim"
export EDITOR="vim"
### Functions ###
# convert hexadecimal to binary and vice-versa
h2d(){
echo "ibase=16; $@"|bc
}
d2h(){
echo "obase=16; $@"|bc
}
8 years ago
findrepo(){
if [ ! -z "$1" ]; then
find "$1" -not -path "*/\.git/*";
else
find . -not -path "*/\.git/*";
fi
}
findrepofiles(){
if [ ! -z "$1" ]; then
find "$1" -type f -not -path "*/\.git/*";
else
find . -type f -not -path "*/\.git/*";
fi
}
# kill baloo utils
baloo_clean(){
sudo killall baloo_file
sudo mv /usr/bin/baloo_file /usr/bin/baloo_file.bak
sudo echo '#!/bin/sh' > /usr/bin/baloo_file
}
# print battery level
battery(){
upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep percentage
}
### Buildroot override ###
export BR2_DL_DIR=~/BR2_DL_DR
8 years ago
# ********COLOR********
# Palette foncée
# \033[01;30m\] : Noir
# \033[01;31m\] : Rouge
# \033[01;32m\] : Vert
# \033[01;33m\] : Jaune
# \033[01;34m\] : Bleu
# \033[01;35m\] : Violet
# \033[01;36m\] : Cyan
# \033[01;37m\] : Gris
# Palette claire
# \033[00;30m\] : Noir
# \033[00;31m\] : Rouge
# \033[00;32m\] : Vert
# \033[00;33m\] : Jaune
# \033[00;34m\] : Bleu
# \033[00;35m\] : Violet
# \033[00;36m\] : Cyan
# \033[00;37m\] : Gris