mirror of
https://github.com/balkian/dotfiles.git
synced 2024-11-23 20:52:28 +00:00
One-instance and bashrc scripts. Plus a modified script to download songs from goear
This commit is contained in:
parent
77599a08ad
commit
cdd5045184
125
bashrc
Normal file
125
bashrc
Normal file
@ -0,0 +1,125 @@
|
||||
# ~/.bashrc: executed by bash(1) for non-login shells.
|
||||
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
|
||||
# for examples
|
||||
|
||||
# If not running interactively, don't do anything
|
||||
[ -z "$PS1" ] && return
|
||||
|
||||
# don't put duplicate lines in the history. See bash(1) for more options
|
||||
# ... or force ignoredups and ignorespace
|
||||
HISTCONTROL=ignoredups:ignorespace
|
||||
|
||||
# append to the history file, don't overwrite it
|
||||
shopt -s histappend
|
||||
|
||||
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
|
||||
HISTSIZE=1000
|
||||
HISTFILESIZE=2000
|
||||
|
||||
# check the window size after each command and, if necessary,
|
||||
# update the values of LINES and COLUMNS.
|
||||
shopt -s checkwinsize
|
||||
|
||||
# make less more friendly for non-text input files, see lesspipe(1)
|
||||
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
|
||||
|
||||
# set variable identifying the chroot you work in (used in the prompt below)
|
||||
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
|
||||
debian_chroot=$(cat /etc/debian_chroot)
|
||||
fi
|
||||
|
||||
# set a fancy prompt (non-color, unless we know we "want" color)
|
||||
case "$TERM" in
|
||||
xterm-color) color_prompt=yes;;
|
||||
xterm) color_prompt=yes;;
|
||||
esac
|
||||
|
||||
# uncomment for a colored prompt, if the terminal has the capability; turned
|
||||
# off by default to not distract the user: the focus in a terminal window
|
||||
# should be on the output of commands, not on the prompt
|
||||
force_color_prompt=yes
|
||||
|
||||
if [ -n "$force_color_prompt" ]; then
|
||||
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
|
||||
# We have color support; assume it's compliant with Ecma-48
|
||||
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
|
||||
# a case would tend to support setf rather than setaf.)
|
||||
color_prompt=yes
|
||||
else
|
||||
color_prompt=
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$color_prompt" = yes ]; then
|
||||
export PROMPT_COMMAND='PS1="\\[\033[1;\`if [[ \$? = "0" ]]; then echo "32m\\]"; else echo "31m\\]"; fi\`[\!]\\[\033[0m\]\u@\h \W: "'
|
||||
else
|
||||
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
|
||||
fi
|
||||
|
||||
unset color_prompt force_color_prompt
|
||||
|
||||
# If this is an xterm set the title to user@host:dir
|
||||
case "$TERM" in
|
||||
xterm*|rxvt*)
|
||||
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# enable color support of ls and also add handy aliases
|
||||
if [ -x /usr/bin/dircolors ]; then
|
||||
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
||||
alias ls='ls --color=auto'
|
||||
#alias dir='dir --color=auto'
|
||||
#alias vdir='vdir --color=auto'
|
||||
|
||||
alias grep='grep --color=auto'
|
||||
alias fgrep='fgrep --color=auto'
|
||||
alias egrep='egrep --color=auto'
|
||||
fi
|
||||
|
||||
# some more ls aliases
|
||||
alias ll='ls -alhF'
|
||||
alias la='ls -A'
|
||||
alias l='ls -CF'
|
||||
|
||||
# Add an "alert" alias for long running commands. Use like so:
|
||||
# sleep 10; alert
|
||||
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
|
||||
|
||||
# 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
|
||||
|
||||
# enable programmable completion features (you don't need to enable
|
||||
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
|
||||
# sources /etc/bash.bashrc).
|
||||
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
|
||||
. /etc/bash_completion
|
||||
fi
|
||||
export CDPATH=~:/media/Datos:/home/balkian
|
||||
|
||||
if [ "$TERM" = "linux" ]; then
|
||||
alias logout="clear && logout && exit"
|
||||
else
|
||||
alias logout="exit 0"
|
||||
fi
|
||||
export PYTHONSTARTUP=/home/$USER/.pythonrc
|
||||
export PATH=$PATH:/var/lib/gems/1.8/bin
|
||||
|
||||
setWindowTitle() {
|
||||
echo -ne "\e]2;$*\a"
|
||||
}
|
||||
updateWindowTitle() {
|
||||
setWindowTitle "${HOSTNAME%%.*}:${PWD/$HOME/~}"
|
||||
}
|
||||
PROMPT_COMMAND=$PROMPT_COMMAND updateWindowTitle
|
||||
|
||||
function findHere() { ex=$1; shift; grep -R $* $ex .;}
|
||||
|
2
gnome-terminal
Executable file
2
gnome-terminal
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
one-window 'gnome-terminal' 'xdotool windowfocus $WID & xdotool key ctrl+shift+t'
|
70
goear.sh
Executable file
70
goear.sh
Executable file
@ -0,0 +1,70 @@
|
||||
#bin/bash
|
||||
resultado=/tmp/resultado
|
||||
canciones=/tmp/canciones
|
||||
enlaces=/tmp/enlaces
|
||||
titulos=/tmp/titulos
|
||||
#Pedimos al usuario el titulo de la canción.
|
||||
echo "Introduce el título de la canción o del artista:"
|
||||
read TITULO
|
||||
|
||||
if [ ! -d "goear" ]
|
||||
then
|
||||
mkdir goear
|
||||
fi
|
||||
#Descargamos el PHP correspondiente al título.
|
||||
wget http://goear.com/search.php?q="$TITULO" -O $resultado
|
||||
|
||||
#La línea 130 contiene todos los enlaces a goear... de risa pero bueno.
|
||||
head -130 $resultado | tail -1 > $canciones
|
||||
|
||||
#Mediante ER, obtenemos una lista de canciones y una lista de enlaces.
|
||||
egrep -o 'listen/......./[^"]*' $canciones > $enlaces
|
||||
egrep -o '"Escuchar[^"]*' $canciones > $titulos
|
||||
|
||||
#Mostramos al usuario los que ha encontrado en la primera página.
|
||||
Linea=1
|
||||
cat $titulos | while read line;
|
||||
do {
|
||||
echo $Linea: ${line:9}
|
||||
let 'Linea += 1'
|
||||
}
|
||||
done
|
||||
|
||||
#Si no encuentra nada, sale.
|
||||
CONDICION=`wc -l $titulos | awk '{print $1}'`
|
||||
if [ $CONDICION == 0 ]; then
|
||||
echo "No hay resultados. Prueba buscando otra cosa."
|
||||
rm $resultado $canciones $enlaces $titulos
|
||||
exit
|
||||
fi
|
||||
|
||||
#Leemos qué canción quiere el usuario bajarse.
|
||||
echo "¿Cuál te quieres bajar? Indica el número:"
|
||||
read NUMERO
|
||||
|
||||
#Concatenamos http://www.goear.com con el contenido de aBajar.txt.
|
||||
#PD: Alguien sabe hacerlo de manera más sencilla?
|
||||
GOEAR=http://www.goear.com/
|
||||
aBajar=`head -$NUMERO $enlaces | tail -1`
|
||||
for LISTEN in $aBajar
|
||||
do
|
||||
ENLACE=${GOEAR}${LISTEN}
|
||||
done
|
||||
echo $ENLACE
|
||||
|
||||
#A partir de aquí el script no es mío, pero es muy sencillo de leer.
|
||||
fileid=`echo $ENLACE | cut -d '/' -f 5`
|
||||
xmlurl="http://www.goear.com/tracker758.php?f="$fileid
|
||||
infoline=`wget -qO- $xmlurl | grep ".mp3"`
|
||||
mp3url=`echo $infoline | cut -d '"' -f6`
|
||||
artist=`echo $infoline | cut -d '"' -f10`
|
||||
title=`echo $infoline | cut -d '"' -f12`
|
||||
filename=goear/"$artist-$title.mp3"
|
||||
wget $mp3url -O "$filename"
|
||||
rm $resultado $canciones $enlaces $titulos
|
||||
|
||||
echo "¿Quieres reproducirla?[Y/n]"
|
||||
read RES
|
||||
if [ -z "$RES" -o "$RES" = "Y" -o "$RES" = "y" ];then
|
||||
mplayer "$filename";
|
||||
fi;
|
25
one-instance
Executable file
25
one-instance
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
if [ "x$1" != "x" ]
|
||||
then
|
||||
pgrep -l -u "$USER" -f "$1" | egrep -v "/bin/bash|/bin/sh" | grep -vq "$$"
|
||||
if [ $? == "0" ]
|
||||
then
|
||||
ps aux | grep terminator > /home/balkian/LOG
|
||||
WID=`xdotool search --class $1 | head -1`
|
||||
wmctrl -i -a $WID
|
||||
if [ "x$2" != "x" ]
|
||||
then
|
||||
eval "$2"
|
||||
fi
|
||||
else
|
||||
if [ "x$3" == "x" ]
|
||||
then
|
||||
/usr/bin/$1
|
||||
else
|
||||
eval "$3"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "Usage: one-instance program-name [extra action]"
|
||||
fi
|
||||
|
27
one-instance (copy)
Executable file
27
one-instance (copy)
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
if [ "x$1" != "x" ]
|
||||
then
|
||||
pgrep -fx $1 1> /dev/null
|
||||
if [ $? == "0" ]
|
||||
then
|
||||
echo "running"
|
||||
ps aux | grep terminator > /home/balkian/LOG
|
||||
WID=`xdotool search --class $1 | head -1`
|
||||
wmctrl -i -a $WID
|
||||
if [ "x$2" != "x" ]
|
||||
then
|
||||
eval "$2"
|
||||
fi
|
||||
else
|
||||
if [ "x$3" == "x" ]
|
||||
then
|
||||
echo "not running"
|
||||
/usr/bin/$1
|
||||
else
|
||||
eval "$3"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "Usage: one-instance program-name [extra action]"
|
||||
fi
|
||||
|
10
one-terminator.sh
Executable file
10
one-terminator.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
pgrep -u "$USER" gnome-terminal | grep -qv "$$"
|
||||
if [ "$?" == "0" ]; then
|
||||
WID=`xdotool search --class "terminator" | head -1`
|
||||
xdotool windowfocus $WID
|
||||
xdotool key ctrl+shift+t
|
||||
#wmctrl -i -a $WID
|
||||
else
|
||||
/usr/bin/gnome-terminal
|
||||
fi
|
25
one-window
Executable file
25
one-window
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
if [ "x$1" != "x" ]
|
||||
then
|
||||
WID=`xdotool search --class $1 | head -1`
|
||||
if [ "s$WID" != "s" ]
|
||||
then
|
||||
ps aux | grep terminator > /home/balkian/LOG
|
||||
|
||||
wmctrl -i -a $WID
|
||||
if [ "x$2" != "x" ]
|
||||
then
|
||||
eval "$2"
|
||||
fi
|
||||
else
|
||||
if [ "x$3" == "x" ]
|
||||
then
|
||||
/usr/bin/$1
|
||||
else
|
||||
eval "$3"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "Usage: one-instance program-name [extra action]"
|
||||
fi
|
||||
|
17
start-eclipse.sh
Normal file
17
start-eclipse.sh
Normal file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
cd $(dirname $(dirname $0))
|
||||
eclipse/eclipse -vm jre1.6.0_20/bin/ || failed=1
|
||||
if [ $failed -eq 1 ]; then
|
||||
|
||||
zenity --warning --title "Error executing eclipse's launcher" --text "Eclipse couldn't be found in $(pwd), please, modify $0 script to point to the right location" || exit
|
||||
file=$(zenity --file-selection --title "Select the right executable");
|
||||
vm=$(zenity --file-selection --title "Select virtual machine");
|
||||
|
||||
echo $file;
|
||||
if [ -n "$file" ]; then
|
||||
if [ -n "$vm" ]; then
|
||||
virt=" -vm $vm";
|
||||
fi
|
||||
$file $virt
|
||||
fi
|
||||
fi
|
2
terminator
Executable file
2
terminator
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
one-window "terminator" "xdotool windowfocus \$WID & xdotool key ctrl+shift+t;" "/usr/bin/terminator $*"
|
Loading…
Reference in New Issue
Block a user