]> git.friedersdorff.com Git - max/dotfiles.git/blob - bash/.bash_aliases
Better text reflowing with mutt
[max/dotfiles.git] / bash / .bash_aliases
1 #!/bin/bash
2
3 if [ -x /usr/bin/dircolors ]; then
4     test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
5     alias ls='ls --color=auto'
6     alias dir='dir --color=auto'
7     alias vdir='vdir --color=auto'
8
9     alias grep='grep --color=auto'
10     alias fgrep='fgrep --color=auto'
11     alias egrep='egrep --color=auto'
12 fi
13
14 function la {
15     ls_out=$(\ls -lah --color=always "$@")
16     let "allowed_lines = $(tput lines) - 3"
17     if [ $(echo "$ls_out" | wc -l) -le $allowed_lines ]; then
18         echo "$ls_out"
19     else
20         echo "$ls_out" | less -r
21     fi
22 }
23 alias tmux='TERM=xterm-256color tmux'
24 if [ -x /usr/bin/gvim ]; then 
25   alias vim='gvim -v'
26 fi
27  
28
29 function ssh_in() {
30   control_file="$TMPDIR/${1}_ssh_in"
31   if [[ -e $control_file ]]; then
32     echo "Session is already open"
33     exit
34   fi
35
36   cat ~/.tmux.conf | ssh \
37     -M \
38     -S "$control_file" \
39     -o ControlPersist=yes \
40     "${1}" \
41     'cat - > ~/.tmux_ssh.conf'
42     
43
44   i3-sensible-terminal -e \
45     sh -c \
46     "ssh \
47       -o RemoteCommand=\"/bin/sh -c 'exec tmux -f ~/.tmux_ssh.conf new -As remote'\" \
48       -S \"$control_file\" \
49       -t \
50       \"$@\"
51     ssh -O exit -S \"$control_file\" \"$1\"" 
52 }