Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

Commit 1f3f6d6

Browse files
committed
first version of the dotcrap file
1 parent dc72375 commit 1f3f6d6

File tree

1 file changed

+189
-0
lines changed

1 file changed

+189
-0
lines changed

dotcrap

+189
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# Dotcrap - A mass of dotfiles crapped out by applications automatically.
2+
#
3+
# Resources:
4+
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
5+
# https://plus.google.com/+RobPikeTheHuman/posts/R58WgWwN9jp
6+
#
7+
# If you source this file then lots of them should be moved out of your home
8+
# directory
9+
10+
# A single base directory relative to which user-specific data files should be
11+
# written.
12+
export XDG_DATA_HOME="$HOME"/.local/share
13+
# A single base directory relative to which user-specific configuration files
14+
# should be written
15+
export XDG_CONFIG_HOME="$HOME"/.config
16+
# A single base directory relative to which user-specific non-essential
17+
# (cached) data should be written
18+
export XDG_CACHE_HOME="$HOME"/.local/cache
19+
# A single base directory relative to which user-specific runtime files and
20+
# other file objects should be placed
21+
export XDG_RUNTIME_DIR="$HOME"/.local/tmp
22+
23+
# Handy function to determine if a command is installed
24+
_has() {
25+
command -v $1>/dev/null 2>&1
26+
}
27+
28+
if _has bash; then
29+
export BASH_COMPLETION_USER_FILE="$XDG_CONFIG_HOME"/bash-completion/bash_completion
30+
fi
31+
32+
if _has tput; then
33+
# Set terminfo location + directories
34+
export TERMINFO="$XDG_DATA_HOME"/terminfo
35+
export TERMINFO_DIRS="$XDG_DATA_HOME"/terminfo:/usr/share/terminfo
36+
fi
37+
38+
if _has node; then
39+
# NODE_REPL_HISTORY sets the location of the node repl history
40+
export NODE_REPL_HISTORY="$XDG_CACHE_HOME"/node/node_history
41+
42+
# Move .babel.json (Babel's cache file, elsewhere)
43+
# Adding this here as you may be running babel via a script or npx etc, so
44+
# the command wouldn't register as being installed directly. But what you
45+
# definitely need is node
46+
export BABEL_CACHE_PATH="$XDG_CACHE_HOME"/babel/babel.json
47+
fi
48+
49+
if _has npm; then
50+
# Move npm config file.
51+
export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME"/npm/npmrc
52+
53+
# Move node-gyp devdir out of .node-gyp
54+
export npm_config_devdir="$XDG_CACHE_HOME"/gyp
55+
56+
# Move npm cache
57+
export npm_config_cache="$XDG_CACHE_HOME"/npm
58+
59+
# Move globally installed packages
60+
export npm_config_prefix="$XDG_DATA_HOME"/npm
61+
62+
# Move tmp directory, will be cleaned on success, but left
63+
# here for forensic purposes on failure
64+
export npm_config_tmp="$XDG_RUNTIME_DIR"/npm
65+
66+
# Set init-module just in case we want to use it later
67+
export npm_config_init_module="$XDG_CONFIG_HOME"/npm/config/npm-init.js
68+
fi
69+
70+
if _has less; then
71+
# Move .lesshst (Less's history file)
72+
export LESSHISTFILE="$XDG_RUNTIME_DIR"/less/history
73+
fi
74+
75+
if _has wget; then
76+
# Move wget stuff out of the home directory
77+
export WGETRC="$XDG_CONFIG_HOME"/wget/wgetrc
78+
fi
79+
80+
81+
if _has tmux; then
82+
# Move tmux's tmp directory
83+
export TMUX_TMPDIR="$XDG_RUNTIME_DIR"/tmux
84+
85+
# This launches tmux with the following options:
86+
#
87+
# -f => sets a config file
88+
alias tmux='tmux -f $XDG_CONFIG_HOME/tmux/conf'
89+
fi
90+
91+
if _has weechat; then
92+
# Move weechat config from .weechat
93+
export WEECHAT_HOME="$XDG_CONFIG_HOME"/weechat
94+
fi
95+
96+
if _has docker; then
97+
# Move docker's config from .docker/
98+
export DOCKER_CONFIG="$XDG_CONFIG_HOME"/docker
99+
fi
100+
101+
if _has kubectl; then
102+
# Move k8s config out of .kube/
103+
export KUBECONFIG="$XDG_CONFIG_HOME"/kube/config
104+
105+
# Launch kubectl with the cache directory set to a proper cache dir
106+
alias kubectl='kubectl --cache-dir $XDG_CACHE_HOME/kube/http'
107+
fi
108+
109+
if _has helm; then
110+
# Helm variable for location of config
111+
export HELM_HOME="$XDG_CONFIG_HOME"/helm/helm
112+
fi
113+
114+
if _has atom; then
115+
# Move atoms junk out of ~/.atom
116+
export ATOM_HOME="$XDG_DATA_HOME"/atom
117+
fi
118+
119+
if _has gpg; then
120+
# Move gpg config files out of ~/.gnupg
121+
export GNUPGHOME="$XDG_CONFIG_HOME"/gnupg
122+
fi
123+
124+
if _has rustup; then
125+
# Move rustup config from ~/.rustup
126+
export RUSTUP_HOME="$XDG_DATA_HOME"/rustup
127+
fi
128+
129+
if _has cargo; then
130+
# Move cargo data out of .cargo
131+
export CARGO_HOME="$XDG_DATA_HOME"/cargo
132+
fi
133+
134+
if _has aws; then
135+
# Move aws-cli config out of ~/.aws
136+
export AWS_CONFIG_FILE="$XDG_CONFIG_HOME"/aws/config
137+
138+
# Move aws-cli credentials out of ~/.aws
139+
export AWS_SHARED_CREDENTIALS_FILE="$XDG_CONFIG_HOME"/aws/credentials
140+
fi
141+
142+
if _has emacs; then
143+
# Move spacemacs config files out of ~/.spacemacs or ~/.spacemacs.d/
144+
export SPACEMACSDIR="$XDG_CONFIG_HOME"/spacemacs
145+
fi
146+
147+
if _has bundle; then
148+
# Move bundle config out of ~/.bundle
149+
export BUNDLE_USER_CONFIG="$XDG_CONFIG_HOME"/bundle
150+
export BUNDLE_USER_CACHE="$XDG_CACHE_HOME"/bundle
151+
export BUNDLE_USER_PLUGIN="$XDG_DATA_HOME"/bundle
152+
fi
153+
154+
if _has gem; then
155+
# Move ruby config out of ~/.gem
156+
export GEM_HOME="$XDG_DATA_HOME"/gem
157+
export GEM_SPEC_CACHE="$XDG_CACHE_HOME"/gem
158+
fi
159+
160+
if _has ansible; then
161+
# Move ansible config out of ~/.ansible
162+
export ANSIBLE_CONFIG="$XDG_CONFIG_HOME"/ansible
163+
fi
164+
165+
if _has travis; then
166+
# Move travis config out of ~/.travis
167+
export TRAVIS_CONFIG_PATH="$XDG_CONFIG_HOME"/travis
168+
fi
169+
170+
if _has git; then
171+
# Set git template directory
172+
export GIT_TEMPLATE_DIR="$XDG_CONFIG_HOME"/git/template
173+
fi
174+
175+
# This check seems shaky, but I don't know enough about android dev to disprove it
176+
if _has adb; then
177+
# Move android config out of ~/.android
178+
export ANDROID_SDK_HOME="$XDG_CONFIG_HOME"/android
179+
fi
180+
181+
if _has code; then
182+
# Launch code with XDG directories specified for data and extensions
183+
alias code='code --user-data-dir $XDG_CONFIG_HOME/vscode --extensions-dir $XDG_RUNTIME_DIR/vscode/extensions'
184+
fi
185+
186+
if _has svn; then
187+
# Sets an alias that moves the config directory out of ~/.subversion
188+
alias svn='svn --config-dir $XDG_CONFIG_HOME/subversion'
189+
fi

0 commit comments

Comments
 (0)