X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=bash%2F.bash_aliases;h=d5cc9d5ca933872062bbcccab5a85f84f5a0cfe1;hb=76ebf038d75f778b27e0e14d855bc295664656ce;hp=879f20c0842763407e4f728a9b1888ad1dac4b62;hpb=17b5704f4ad364c4f4ca206413925e3e62cb844e;p=max%2Fdotfiles.git diff --git a/bash/.bash_aliases b/bash/.bash_aliases index 879f20c..d5cc9d5 100644 --- a/bash/.bash_aliases +++ b/bash/.bash_aliases @@ -1,3 +1,5 @@ +#!/bin/bash + if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" alias ls='ls --color=auto' @@ -10,6 +12,41 @@ if [ -x /usr/bin/dircolors ]; then fi function la { - \ls -lah --color=always "$@" | less -r + 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\"" +}