Added some utilities:
authorpatrick nsukami <ndkpatt@gmail.com>
Sun, 9 Nov 2014 19:28:41 +0000 (19:28 +0000)
committerpatrick nsukami <ndkpatt@gmail.com>
Sun, 9 Nov 2014 19:28:41 +0000 (19:28 +0000)
- functions to quickly switch to a python venv and activate it
- functions to find current git repo/branch/status/stash
- extended the xtract function to handle xz extensions
- removed a space/comment in the bashrc
- aliases to list installed packages

.bash_aliases
.bash_function
.bashrc

index 5a4a5d1..fcbb608 100644 (file)
@@ -1,6 +1,9 @@
 #!/bin/sh
 # my weird aliases
 
+alias my_installed_packages="dpkg --get-selections"
+alias my_manually_installed_packages="aptitude search '~i !~M'"
+
 alias my_tcp_sockets='ss -s'
 alias my_tcp_sockets2='netstat -s'
 alias my_open_ports2='ss -l'
index 3f5123b..4992cdc 100644 (file)
@@ -1,6 +1,60 @@
 #!/bin/sh
 # my weird function file
 
+my_venv_list(){
+    ls $HOME"/envs"
+}
+
+my_venv_goto() {
+    local dir=$1
+    local env=$HOME"/envs/"$dir"/source/"
+    cd $env
+    source activate
+}
+
+# Taken from http://aaroncrane.co.uk/2009/03/git_branch_prompt/
+find_git_repo() {
+    local dir=.
+    until [ "$dir" -ef / ]; do
+        if [ -f "$dir/.git/HEAD" ]; then
+            GIT_REPO=`readlink -e $dir`/
+            return
+        fi
+        dir="../$dir"
+    done
+    GIT_REPO=''
+    return
+}
+
+find_git_branch() {
+    head=$(< "$1/.git/HEAD")
+    if [[ $head == ref:\ refs/heads/* ]]; then
+        GIT_BRANCH=${head#*/*/}
+    elif [[ $head != '' ]]; then
+        GIT_BRANCH='(detached)'
+    else
+        GIT_BRANCH='(unknown)'
+    fi
+}
+
+# Taken from https://github.com/jimeh/git-aware-prompt
+find_git_dirty() {
+  local status=$(git status --porcelain 2> /dev/null)
+  if [[ "$status" != "" ]]; then
+    GIT_DIRTY='*'
+  else
+    GIT_DIRTY=''
+  fi
+}
+
+find_git_stash() {
+    if [ -e "$1/.git/refs/stash" ]; then
+        GIT_STASH='stash'
+    else
+        GIT_STASH=''
+    fi
+}
+
 cdls() { cd "$@" && clear && ls; }
 
 
@@ -131,7 +185,8 @@ my_xtract() {
 
     if is_file $filename ; then
         case $filename in
-        *.tar.xz)    tar xvfJ $filename     ;;
+            *.tar.xz)    tar xvfJ $filename     ;;
+            *.xz)        tar xf $filename       ;;
             *.tar.bz2)   tar xvjf $filename     ;;
             *.tar.gz)    tar xvzf $filename     ;;
             *.bz2)       bunzip2 $filename      ;;
diff --git a/.bashrc b/.bashrc
index e304fdb..327d7e2 100644 (file)
--- a/.bashrc
+++ b/.bashrc
@@ -139,5 +139,3 @@ fi
 
 # emacs launcher script
 [[ -f ~/.bash_emacs ]] && . ~/.bash_emacs
-
-# woops