-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.shellrc
More file actions
executable file
·133 lines (108 loc) · 3.23 KB
/
.shellrc
File metadata and controls
executable file
·133 lines (108 loc) · 3.23 KB
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
#!/bin/bash
source ~/.env
source-if-exists $HOME/bin/keychain-init.sh
source "$HOME/.aliases"
ealias solarized-switch="source $HOME/bin/solarized-switch.sh"
source $HOME/bin/solarized-switch.sh $SOLARIZED
# Encryption / Decryption Functions
encrypt () {
gpg -ac --no-options "$1"
}
decrypt () {
gpg --no-options "$1"
}
# cd and ls
cdl() {
cd "$1" || return
shift;
ls $@
}
# mkdir and cd
mdcd () {
mkdir "$1";
cd "$1" || return
}
function venv() {
source $1/bin/activate
}
# A shortcut function that simplifies usage of xclip.
# - Accepts input from either stdin (pipe), or params.
# From: http://madebynathan.com/2011/10/04/a-nicer-way-to-use-xclip/
# ------------------------------------------------
cb() {
local _scs_col="\e[0;32m"; local _wrn_col='\e[1;31m'; local _trn_col='\e[0;33m'
# Check that xclip is installed.
if ! type xclip > /dev/null 2>&1; then
echo -e "$_wrn_col""You must have the 'xclip' program installed.\e[0m"
# Check user is not root (root doesn't have access to user xorg server)
elif [[ "$USER" == "root" ]]; then
echo -e "$_wrn_col""Must be regular user (not root) to copy a file to the clipboard.\e[0m"
else
# If no tty, data should be available on stdin
if ! [[ "$( tty )" == /dev/* ]]; then
input="$(< /dev/stdin)"
# Else, fetch input from params
else
input="$*"
fi
if [ -z "$input" ]; then # If no input, print usage message.
echo "Copies a string to the clipboard."
echo "Usage: cb <string>"
echo " echo <string> | cb"
else
# Copy input to clipboard
echo -n "$input" | xclip -selection c
# Truncate text for status
if [ ${#input} -gt 80 ]; then input="$(echo $input | cut -c1-80)$_trn_col...\e[0m"; fi
# Print status.
echo -e "$_scs_col""Copied to clipboard:\e[0m $input"
fi
fi
}
# Aliases / functions leveraging the cb() function
# ------------------------------------------------
# Copy contents of a file
function cbf() { cat "$1" | cb; }
# Copy current working directory
ealias cbwd="pwd | cb"
# Copy most recent command in bash history
ealias cbhs="cat $HISTFILE | tail -n 1 | cb"
export LESS=-R
# turn off bold/blink/standout
export LESS_TERMCAP_me=$(printf '\e[0m')
# stop standout
export LESS_TERMCAP_se=$(printf '\e[0m')
# stop underline
export LESS_TERMCAP_ue=$(printf '\e[0m')
# blink
export LESS_TERMCAP_mb=$(printf '\e[1;32m')
# bold
#export LESS_TERMCAP_md=$(printf '\e[1;34m')
export LESS_TERMCAP_md=$(printf '\e[1;36m')
# underline
#export LESS_TERMCAP_us=$(printf '\e[1;32m')
# standout
export LESS_TERMCAP_so=$(printf '\e[1;44;1m')
#eval $(ssh-agent)
#ssh-add ~/.ssh/id_rsa
#ssh-add ~/.ssh/*
#source $HOME/run-gpg
#eval $(keychain --eval --agents ssh -Q --quiet ~/.ssh/id_rsa)
disp () {
export DISPLAY=:$1
}
# NVM_DIR var in .env
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
eval "$(fasd --init auto)"
# Stops Ctrl-S from suspending output to allow forward history search instead
stty -ixon
#source ~/bin/resty
source-if-exists .shell/proxy.sh
# for 'hotel' package
# proxy_on 127.0.0.1:2000
# OPAM configuration
if [ $ZSH_NAME ]; then
. $HOME/.opam/opam-init/init.zsh > /dev/null 2> /dev/null || true
else
. $HOME/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true
fi