-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc
81 lines (66 loc) · 2 KB
/
.bashrc
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
#!/bin/bash
# -------------------------------
# If not running interactively,
# don't do anything and
# return early. Stops SFTP error
# 'Received message too long'
# -------------------------------
[[ $- == *i* ]] || return
# -------------------------------
# Set up variables
# -------------------------------
SITE_NAME=$(wp --skip-plugins --skip-themes option get blogname 2>/dev/null)
export EDITOR=nano
# -------------------------------
# Set up prompt
# -------------------------------
export PS1="\[\e[36m\]\u\[\e[37m\]@\[\e[32m\]$DOMAIN_NAME:\[\e[33m\]\w\[\e[37m\]\$ "
export PS2="| => "
# -------------------------------
# iTerm integration
# -------------------------------
test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash" || true
source "${HOME}/.iterm2_shell_integration.bash"
# Adds hostname title and badge to iTerm2
printf "\e]1337;SetBadgeFormat=%s\a" "$(echo -n Pressable: "$SITE_NAME" | base64)"
echo -ne "\033]0;Pressable: $SITE_NAME\007"
# -------------------------------
# Aliases
# -------------------------------
# Tail PHP logs
alias logs='tail -F /tmp/php-errors'
# LS settings
alias ls="ls --color=auto"
# -------------------------------
# Custom Functions
# -------------------------------
# Update bashrc from GitHub!
function update_bashrc() {
if curl -s -f -o ~/.bashrc https://raw.githubusercontent.com/emrikol/pressable-user-environment/main/.bashrc; then
source "${HOME}/.bashrc"
echo "Updated .bashrc successfully"
else
echo "Failed to download .bashrc from GitHub"
fi
}
# ack isn't installed, fall back to grep.
function ack() {
if which ack >/dev/null 2>&1; then
# run the original ack command
command ack "$@"
else
# run grep instead
grep --color -rHn "$@"
fi
}
# pbcopy via iTerm2
function pbcopy() {
if which pbcopy >/dev/null 2>&1; then
pbcopy "$@"
else
# Replace ^[ with the ASCII escape character
local start="\e]1337;CopyToClipboard\a"
local end="\e]1337;EndCopy\a"
printf "${start}$(cat)${end}"
fi
}