-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_aliases
107 lines (85 loc) · 3.18 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
#!/bin/bash
# Automatically change directory
shopt -s autocd
# Case-insensitive completion
bind 'set completion-ignore-case on'
# If there are multiple matches for completion, Tab should cycle through them
bind 'TAB:menu-complete'
# And Shift-Tab should cycle backwards
bind '"\e[Z": menu-complete-backward'
# Display a list of the matching files
bind "set show-all-if-ambiguous on"
# Avoid showing "Display all X possibilities (y/n)" too early
bind 'set completion-query-items 1000'
# Perform partial (common) completion on the first Tab press, only start
# cycling full results on the second Tab press (from bash version 5)
bind "set menu-complete-display-prefix on"
# Cycle through history based on characters already typed on the line
bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'
# Keep Ctrl-Left and Ctrl-Right working when the above are used
bind '"\e[1;5C":forward-word'
bind '"\e[1;5D":backward-word'
alias create-venv="python3 -m venv --prompt venv --upgrade-deps .venv"
alias ll="ls -l"
alias la="ls -la"
# Automatically activate Python's virtualenv when changing directory
function cd() {
builtin cd "$@" || exit
if [ -d .venv ]; then
source .venv/bin/activate
fi
}
# PastBoard aliases
if [[ -n "$WAYLAND_DISPLAY" ]]; then
alias pbcopy="wl-copy"
alias pbpaste="wl-paste"
else
alias pbcopy="xsel --clipboard --input"
alias pbpaste="xsel --clipboard --output"
fi
# FZF integration
if [ -f /usr/share/doc/fzf/examples/key-bindings.bash ]; then
source /usr/share/doc/fzf/examples/key-bindings.bash
fi
# Powerline prompt
if [ -f /usr/share/powerline/integrations/powerline.sh ]; then
source /usr/share/powerline/integrations/powerline.sh
fi
# Odoo toolbelt
ODOO_DATABASE_NAME=odoodb
alias odorun="python odoo/odoo-bin --database=$ODOO_DATABASE_NAME --workers=0 --max-cron-threads=0 --dev=xml,reload"
alias odorun-ent="odorun --addons-path=odoo/addons,enterprise"
alias odoinit="python odoo/odoo-bin --database=$ODOO_DATABASE_NAME --workers=0 --max-cron-threads=0 --dev=xml --stop-after-init"
alias odoinit-ent="odoinit --addons-path=odoo/addons,enterprise"
alias odotest="odoinit --test-enable"
alias odotest-ent="odotest --addons-path=odoo/addons,enterprise"
alias ododrop="dropdb $ODOO_DATABASE_NAME --if-exists && rm -rf $HOME/.local/share/Odoo"
function odoget() {
DB_URL=$1
echo "Restoring from $DB_URL"
zipname=$(basename "$DB_URL")
dbname=${zipname%.*}
tmp_restore_path="/tmp/restore-$dbname"
if [ -d "$tmp_restore_path" ]; then
rm -r "$tmp_restore_path"
fi
mkdir "$tmp_restore_path"
echo "Downloading..."
wget "$DB_URL" -P "$tmp_restore_path"
unzip "$tmp_restore_path/$zipname" -d "$tmp_restore_path"
echo "Restoring filestore..."
filestore_path="$HOME/.local/share/Odoo/filestore/$dbname"
if [ -d "$filestore_path" ]; then
rm -r "$filestore_path"
fi
mkdir "$filestore_path"
mv "$tmp_restore_path"/filestore/* "$filestore_path"
echo "Restoring database..."
dropdb "$dbname" --if-exists
createdb "$dbname"
psql -q "$dbname" < "$tmp_restore_path/dump.sql"
echo "Cleaning up..."
rm -r "$tmp_restore_path"
echo "Created db in $dbname"
}