From f2b32d25177be465c7209072eb93ae14fc16dfa3 Mon Sep 17 00:00:00 2001 From: Tslil Clingman Date: Fri, 9 Aug 2013 14:03:45 +0200 Subject: The vcs script I use for my PS1 and some minor changes --- aur | 6 +++--- ce | 13 +++++++++++++ d | 13 ------------- ranpas | 9 ++++++--- vcs | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+), 19 deletions(-) create mode 100755 ce delete mode 100755 d create mode 100755 vcs diff --git a/aur b/aur index 8d5b071..dfe68c1 100755 --- a/aur +++ b/aur @@ -7,7 +7,7 @@ if [ "$1" = "-s" ]; then exit fi; -cd prog/aur +cd ~/prog/aur echo Pulling... wget "https://aur.archlinux.org/packages/`echo $1|cut -b 1-2`/$1/$1.tar.gz" @@ -25,5 +25,5 @@ if [ -f "$1.tar.gz" ]; then name=$1"-`sed -n 's/pkgver=//p' PKGBUILD`-`sed -n 's/pkgrel=//p' PKGBUILD`" echo Installing... sudo pacman -U $name*.xz - fi; -fi; + fi +fi diff --git a/ce b/ce new file mode 100755 index 0000000..982e885 --- /dev/null +++ b/ce @@ -0,0 +1,13 @@ +# Smart directory changer using the power of grep ;) +# source in a function j() { cd `d $*`} or some such +#!/bin/bash +[ "$1" = "$HOME" ] && echo $HOME && exit +fl="$HOME/.local/share/dir_lst";[ ! -f "$fl" ] && touch "$fl" +[ "$2" = "!" ] && echo "$1" && exit || \ +ln=`grep -n "$1" "$fl" | head -n 1 | cut -d : -f 1` +if [ ! "$1" = "" ]; then if [ ! "$ln" = "" ]; then +echo -e "$ln m0\n1p\nw"|ed -s "$fl"||echo \?; else +l=$1; while [ ! -d "$l" ]; do echo \?; read l; done; +l=`echo "$l" | sed "s|^[^/]|$PWD/&|"`; +echo -e "0i\n$l\n.\n1p\nw" | ed -s "$fl"; sed -i '43,$d' "$fl" +fi; else echo -e "2 m0\n1p\nw" | ed -s "$fl"; fi; diff --git a/d b/d deleted file mode 100755 index 982e885..0000000 --- a/d +++ /dev/null @@ -1,13 +0,0 @@ -# Smart directory changer using the power of grep ;) -# source in a function j() { cd `d $*`} or some such -#!/bin/bash -[ "$1" = "$HOME" ] && echo $HOME && exit -fl="$HOME/.local/share/dir_lst";[ ! -f "$fl" ] && touch "$fl" -[ "$2" = "!" ] && echo "$1" && exit || \ -ln=`grep -n "$1" "$fl" | head -n 1 | cut -d : -f 1` -if [ ! "$1" = "" ]; then if [ ! "$ln" = "" ]; then -echo -e "$ln m0\n1p\nw"|ed -s "$fl"||echo \?; else -l=$1; while [ ! -d "$l" ]; do echo \?; read l; done; -l=`echo "$l" | sed "s|^[^/]|$PWD/&|"`; -echo -e "0i\n$l\n.\n1p\nw" | ed -s "$fl"; sed -i '43,$d' "$fl" -fi; else echo -e "2 m0\n1p\nw" | ed -s "$fl"; fi; diff --git a/ranpas b/ranpas index 2681bf2..4ee1188 100755 --- a/ranpas +++ b/ranpas @@ -2,9 +2,10 @@ #!/bin/bash echo Fetching paste list ... -lst="$(wget pastie.org/pastes -q -O - | sed -n "0,/[\ \t]*e=\$('paste_/s///p" | tr -d "');")" +lst=`wget pastie.org/pastes -q -O - | grep "id='paste" | head -n 1 | sed "s/.*id='paste_\([0-9]*\)'.*/\1/"` echo Newest paste is $lst. +r="" while :; do rnd="$(ruby -e "$><<1+rand($lst)")" echo -e "\n"Looking up paste $rnd ... @@ -16,12 +17,14 @@ while :; do else less /tmp/paste-$rnd echo -n Save?\ - [ "$(line)" = "y" ] && echo Saving as paste $rnd in $HOME && cp /tmp/paste-$rnd $HOME + read r + [ "$r" = "y" ] && echo Saving as paste $rnd in $HOME && cp /tmp/paste-$rnd $HOME fi; else echo Empty paste. fi; rm /tmp/paste-$rnd echo -n Quit?\ - [ "$(line)" = "y" ] && exit + read r + [ "$r" = "y" ] && exit done; diff --git a/vcs b/vcs new file mode 100755 index 0000000..aee37cf --- /dev/null +++ b/vcs @@ -0,0 +1,47 @@ +#!/bin/zsh + +check() { + echo $1 | grep -q $2; +}; + +VCS_STR="" +VCS_INF="" +VCS_NEW="" +VCS_MOD="" +VCS_REC="" + +nstr=" %F{red}●%f" +mstr=" %F{11}●%f" +rstr=" %F{28}●%f" + +if [[ -d ".git" || -d "../.git" || -d "../../.git" ]]; then + outp=$(git status) + VCS_STR="×" + VCS_INF=$(echo $outp | head -n 1 | cut -d' ' -f 4-) + check $outp "^# Untracked files:$" + [[ $? = 0 ]] && VCS_NEW=$nstr + check $outp "^# Changes not staged for commit:$" + [[ $? = 0 ]] && VCS_MOD=$mstr + check $outp "^# Changes to be committed:$" + [[ $? = 0 ]] && VCS_REC=$rstr +else if [[ -d "_darcs" || -d "../_darcs" || -d "../../_darcs" ]]; then + fls=$(darcs show files) + VCS_STR="+" + VCS_INF=$(darcs show repo | grep Default | cut -d : -f 3-) + for f in ./*; do + if [[ -f $f ]]; then + echo $fls | grep -q $f + else + true + fi; + if [[ ! $? = 0 ]]; then + VCS_NEW=$nstr; + break; + fi; + done; + news=$(darcs what)$ + check $news "^No changes!$" + [[ ! $? = 0 ]] && VCS_REC=$rstr +fi; fi; + +[[ ! "$VCS_STR" = "" ]] && echo "%F{green}$VCS_STR%f{%F{blue}$VCS_INF%f$VCS_REC$VCS_MOD$VCS_NEW}" -- cgit v1.2.3