]> git.friedersdorff.com Git - max/saltfiles.git/commitdiff
Source aliases from generic ~/.shell_aliases
authorMaximilian Friedersdorff <max@friedersdorff.com>
Wed, 17 Jul 2019 09:17:51 +0000 (10:17 +0100)
committerMaximilian Friedersdorff <max@friedersdorff.com>
Wed, 17 Jul 2019 09:17:51 +0000 (10:17 +0100)
states/aliases/files/aliases [new file with mode: 0644]
states/aliases/init.sls [new file with mode: 0644]
states/bash/files/bashrc
states/bash/init.sls

diff --git a/states/aliases/files/aliases b/states/aliases/files/aliases
new file mode 100644 (file)
index 0000000..d5cc9d5
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+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
+
+function la {
+    ls_out=$(\ls -lah --color=always "$@")
+    let "allowed_lines = $(tput lines) - 3"
+    if [ $(echo "$ls_out" | wc -l) -le $allowed_lines ]; then
+       echo "$ls_out"
+    else
+       echo "$ls_out" | less -r
+    fi
+}
+alias tmux='TERM=xterm-256color tmux'
+if [ -x /usr/bin/gvim ]; then 
+  alias vim='gvim -v'
+fi
+
+function ssh_in() {
+  control_file="$TMPDIR/${1}_ssh_in"
+  if [[ -e $control_file ]]; then
+    echo "Session is already open"
+    exit
+  fi
+
+  cat ~/.tmux.conf | ssh \
+    -M \
+    -S "$control_file" \
+    -o ControlPersist=yes \
+    "${1}" \
+    'cat - > ~/.tmux_ssh.conf'
+    
+
+  i3-sensible-terminal -e \
+    sh -c \
+    "ssh \
+      -o RemoteCommand=\"/bin/sh -c 'exec tmux -f ~/.tmux_ssh.conf new -As remote'\" \
+      -S \"$control_file\" \
+      -t \
+      \"$@\"
+    ssh -O exit -S \"$control_file\" \"$1\"" 
+}
diff --git a/states/aliases/init.sls b/states/aliases/init.sls
new file mode 100644 (file)
index 0000000..96d442c
--- /dev/null
@@ -0,0 +1,7 @@
+install aliases file:
+  file.managed:
+    - name: {{ grains['homedir'] }}/.shell_aliases
+    - source: salt://aliases/files/aliases
+    - mode: 640
+    - user: {{ grains['user'] }}
+    - group: {{ grains['user'] }}
index 639cca10050c4b9e312cf27884cff01f290d7612..a71321a9454b59694eca2db7e2d33f84a89c15ae 100644 (file)
@@ -17,8 +17,8 @@ HISTFILESIZE=20000
 # update the values of LINES and COLUMNS.
 shopt -s checkwinsize
 
-if [ -f ~/.bash_aliases ]; then
-  . ~/.bash_aliases
+if [ -f ~/.shell_aliases ]; then
+  . ~/.shell_aliases
 fi
 
 
index f0301c5f9d2d86080431d9379a1a7bb8fbaae1ed..fc81c9864e5234e8d6af5a88e4cca0d936b2c148 100644 (file)
@@ -5,10 +5,10 @@ bash installed:
 
 include: 
   - user.max
+  - aliases
 
 {%
   set files = [
-    'bash_aliases',
     'bash_profile',
     'bashrc',
     'dir_colors',