]> id.pley.net Git - dotfiles.git/blobdiff - .aliases
Add ssh-helper functions.
[dotfiles.git] / .aliases
index 57300aeafea6d9efb70470e0ffbbd00be6158387..77c68f09d11dbf89f03ff1eaa570de98adcaf22b 100755 (executable)
--- a/.aliases
+++ b/.aliases
@@ -1,11 +1,14 @@
 #!/bin/bash
 
 # The following aliases vary depending on the host OS:
 #!/bin/bash
 
 # The following aliases vary depending on the host OS:
-if [[ "x$(uname -s)" == "xLinux" ]]; then
-    alias ls='ls -F --color=auto'
-elif [[ "x$(uname -s)" == "xDarwin" ]]; then
-    alias ls='ls -FG'
-fi
+case "$(uname -s)" in
+    Linux )
+        alias ls='ls -F --color=auto'
+        ;;
+    Darwin )
+        alias ls='ls -FG'
+        ;;
+esac
 
 alias m='pine'
 alias beep='echo \a'
 
 alias m='pine'
 alias beep='echo \a'
@@ -61,3 +64,35 @@ function ssh-learn() {
     ssh-keyscan -t rsa $1 >> ~/.ssh/known_hosts
 }
 
     ssh-keyscan -t rsa $1 >> ~/.ssh/known_hosts
 }
 
+function _ssh_complete() {
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    opts=$( grep -o '^[^, ]\+' ~/.ssh/known_hosts )
+    COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+    return 0
+}
+complete -F _ssh_complete ssh
+
+function _ssh_screen () {
+    DISCONNECT=""
+    RECONNECT="-R"
+    HOST=$1
+    while [ "$2" != "" ]; do
+        case $2 in
+            -d | --disconnect )
+                DISCONNECT="-D"
+                ;;
+            * )
+                echo "Usage: $HOST [-d | --discconnect]"
+                return 1
+                ;;
+        esac
+        shift
+    done
+
+    ssh -t $HOST screen $DISCONNECT $RECONNECT
+}
+
+for host in ssh_hosts=$( grep '^Host[ ][^*]' ~/.ssh/config | cut -c 6- ); do
+    alias "$host"="_ssh_screen $host $@"
+done