]> git.friedersdorff.com Git - max/saltfiles.git/blob - states/aliases/files/aliases
Support searching for term
[max/saltfiles.git] / states / aliases / files / aliases
1 if [ -x /usr/bin/dircolors ]; then
2     alias ls='ls --color=auto'
3     alias dir='dir --color=auto'
4     alias vdir='vdir --color=auto'
5     alias grep='grep --color=auto'
6     alias fgrep='fgrep --color=auto'
7     alias egrep='egrep --color=auto'
8 fi
9
10 function la {
11     ls_out=$(\ls -lah --color=always "$@")
12     let "allowed_lines = $(tput lines) - 3"
13     if [ $(echo "$ls_out" | wc -l) -le $allowed_lines ]; then
14         echo "$ls_out"
15     else
16         echo "$ls_out" | less -r
17     fi
18 }
19 alias tmux='TERM=xterm-256color tmux'
20 if [ -x /usr/bin/gvim ]; then 
21   alias vim='gvim -v'
22 fi
23  
24
25 function ssh_in() {
26   control_file="$TMPDIR/${1}_ssh_in"
27   if [[ -e $control_file ]]; then
28     echo "Session is already open"
29     exit
30   fi
31
32   cat ~/.tmux.conf | ssh \
33     -M \
34     -S "$control_file" \
35     -o ControlPersist=yes \
36     "${1}" \
37     'cat - > ~/.tmux_ssh.conf'
38     
39
40   i3-sensible-terminal -e \
41     sh -c \
42     "ssh \
43       -o RemoteCommand=\"/bin/sh -c 'exec tmux -f ~/.tmux_ssh.conf new -As remote'\" \
44       -S \"$control_file\" \
45       -t \
46       \"$@\"
47     ssh -O exit -S \"$control_file\" \"$1\"" 
48 }
49
50 function search() {
51         quoted=$(python -c "import urllib.parse, sys; print(urllib.parse.quote_plus(' '.join(sys.argv[1:])))" "${@}")
52         w3m "https://duckduckgo.com/?q=${quoted}"
53 }