Skip to content

Commit b4ee9c5

Browse files
committed
Add install script and install one-liner
1 parent f5dec62 commit b4ee9c5

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ stop Wed 07 Oct 2020 05:00:00 AM UTC
2121
3. For persistence, add it to your .bashrc or similar:
2222
* `source "$HOME/.cmdw"`
2323

24+
Install one-liner: `source <(curl -s https://raw.githubusercontent.com/0xZDH/cmdw/master/install.sh)`
25+
2426
## History Size:
2527
If required, the user can modify the size of the maintained history file by setting CMDWSIZE as an environment variable (Default: 3,000):
2628
* `export CMDWSIZE=1000`

install.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
#######################################
3+
# Automate the install process for .cmdw
4+
# wrapper.
5+
#
6+
# Install:
7+
# source <(curl -s https://raw.githubusercontent.com/0xZDH/cmdw/master/install.sh)
8+
#######################################
9+
10+
# Validate the current terminal is Bash or Zsh.
11+
[ -n "$BASH_VERSION" -o -n "$ZSH_VERSION" ] || return 0
12+
13+
# Download cmdw.sh to our home directory. Force the file
14+
# to be overwritten when it exists to allow for updates
15+
# to be installed.
16+
curl -s -o "$HOME/.cmdw" \
17+
-q "https://raw.githubusercontent.com/0xZDH/cmdw/master/cmdw.sh"
18+
19+
# Identify current shell type
20+
[ -n "$ZSH_VERSION" ] && \
21+
shell_file="$HOME/.zshrc" || \
22+
shell_file="$HOME/.bashrc"
23+
24+
# Add .cmdw to our shell profile
25+
[ ! "$( grep 'source $HOME/.cmdw' "$shell_file" )" ] && \
26+
echo '[ -f $HOME/.cmdw ] && source $HOME/.cmdw' >> "$shell_file"
27+
28+
# Reload our shell profile
29+
source "$shell_file"
30+
31+
# Clean up
32+
unset shell_file

0 commit comments

Comments
 (0)