-
Notifications
You must be signed in to change notification settings - Fork 2
/
.bash_aliases
157 lines (130 loc) · 4.8 KB
/
.bash_aliases
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# My Bash aliases and other Bash stuff
# Make sure this file is sourced by the shell
alias ls='ls --color=auto'
alias l='ls'
alias ll='ls -l'
alias la='ls -a'
alias lla='ls -la'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias ..2="cd ../.."
alias ..3="cd ../../.."
alias ..4="cd ../../../.."
alias ..5="cd ../../../../.."
alias g='git'
alias s='sudo'
alias v=vim
alias gdb='gdb --quiet' # suppress the introductory and copyright messages
alias xo=xdg-open
# copy with a progress bar
alias cpv="rsync -poghb --backup-dir=/tmp/rsync -e /dev/null --progress --"
# untested rsync aliases (copy/move with progress bar)
alias rsynccopy="rsync --partial --progress --append --rsh=ssh -r -h "
alias rsyncmove="rsync --partial --progress --append --rsh=ssh -r -h --remove-sent-files"
alias sshtunnel="ssh -ND 4711 -v -p 8383 [email protected]"
# for Red Hat based distros
test -e /usr/bin/vimx && alias vim='/usr/bin/vimx'
# Compress the cd, ls -l series of commands.
function cl() {
if [ $# = 0 ]; then
cd && ll
else
cd "$*" && ll
fi
}
# Pronounce an English word using Merriam-Webster.com
pronounce() {
wget -qO- $(wget -qO- "http://www.m-w.com/dictionary/$@" | grep 'return au' | sed -r "s|.*return au\('([^']*)', '([^'])[^']*'\).*|http://cougar.eb.com/soundc11/\2/\1|") | aplay -q;
}
# awk calculator (remember to quote arguments if they contain parentheses)
c ()
{
awk "BEGIN{ pi=4.0*atan2(1.0,1.0); deg=pi/180.0; print $* }";
}
ssh()
{
if [[ "$2" == "" ]]; then
# tmux is like screen, but with ctrl-b as escape char (instead
# of ctrl-a). And it doesn't mess up Vim colors.
command ssh "$1" -Xt tmux new-session -A -s main
# Byobu's most important keybindings:
# F2 - Create a new window
# F3 - Move to previous window
# F4 - Move to next window
# F6 - Detach from this session
# For more, see byobu(1) and look for "KEYBINDINGS".
#command ssh "$1" -Xt byobu-tmux
else
command ssh "$@"
fi
}
genpasswd() {
local len="$1"
test "$len" == "" && len=16
tr -dc "A-Za-z0-9" < /dev/urandom | head -c "$len"; printf "\n"
}
#alias cdl='cl'
# prevent annoying typo's
#alias lc='cl'
#alias todo='vim $HOME/todo.txt'
#alias t='todo'
alias gtd='vim ~/raid/projects/vim-wiki/index.txt'
#alias gtd='vim -c "cd %:h" ~/raid/documents/vim-wiki/index.txt'
# Remember 'sudo apt-get install libnotify-bin' for this.
# Usage: sleep 5; alert
# (this alias is actually in .bashrc in Ubuntu 10.10)
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1| sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias nix-shell-callPackage="nix-shell -E '(import <nixpkgs> {}).callPackage ./. {}'"
alias nix-build-callPackage="nix-build -E '(import <nixpkgs> {}).callPackage ./. {}'"
#export PS1="\[\033[1;30m\]\[\033[1;34m\]\W\[\033[1;30m\] $ "
#export PS1="\W $ "
#export PS1="\[\033[1;30m\][\[\033[1;34m\]\u\[\033[1;30m\]@\[\033[0;35m\]\h\[\033[1;30m\]] \[\033[0;37m\]\W \[\033[1;30m\]\$\[\033[0m\] "
#export PS1='\u@\h:\w$(__git_ps1 " [git::%s]")$ '
export CDPATH=.:~:~/projects
export EDITOR=vim
export BROWSER=firefox
alias e="$EDITOR"
export HISTCONTROL=ignoreboth # ignorespace + ignoredups
export HISTSIZE=1000000 # big big history
export HISTFILESIZE=$HISTSIZE
shopt -s histappend # append to history, don't overwrite it
export LESS="--ignore-case"
# This is a fix for nixpkgs programs. They get broken fonts on non-NixOS
# distros without this. Eelco says that this is a regression (it used to work
# before).
#export FONTCONFIG_FILE=/etc/fonts/fonts.conf
## Save and reload the history after each command finishes
##export PROMPT_COMMAND="history -a; history -r; $PROMPT_COMMAND"
#export PROMPT_COMMAND="history -a; history -n"
# Don't add duplicate ~/.nix-profile/bin to PATH on NixOS
if [ "$(. /etc/os-release; echo $ID)" != nixos -a -d $HOME/.nix-profile/bin ]; then
export PATH=$HOME/.nix-profile/bin:$HOME/.nix-profile/sbin:$PATH
fi
# (Copied from https://mg.pov.lt/blog/bash-prompt.html)
#
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
# Show the currently running command in the terminal title:
# http://www.davidpashley.com/articles/xterm-titles-with-bash.html
show_command_in_title_bar()
{
case "$BASH_COMMAND" in
*\033]0*)
# The command is trying to set the title bar as well;
# this is most likely the execution of $PROMPT_COMMAND.
# In any case nested escapes confuse the terminal, so don't
# output them.
;;
*)
echo -ne "\033]0;${USER}@${HOSTNAME}: ${BASH_COMMAND}\007"
;;
esac
}
trap show_command_in_title_bar DEBUG
;;
*)
;;
esac