Dash to underscore in filenames.

This commit is contained in:
Cyteen May 2020-02-18 03:42:41 +00:00
parent 0d1487fc6a
commit 7552a15d07
6 changed files with 135 additions and 132 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
apt-get -y install grc
ALIAS_HOME=~/.zsh_aliases.d/
ALIAS_FILE=${ALIAS_HOME}/003-grc.sh
ALIAS_FILE=${ALIAS_HOME}/003_grc.sh
mkdir -p ${ALIAS_HOME}

View File

@ -32,11 +32,3 @@ apt-get -f install
# --icon <icon>... When to print the icons [default: auto] [possible values: always, auto, never]
# --icon-theme <icon-theme>... Whether to use fancy or unicode icons [default: fancy] [possible values: fancy, unicode]
mkdir -p ~/.zsh_aliases.d/
ALIAS_FILE=~/.zsh_aliases.d/003-lsd.sh
cat > ${ALIAS_FILE} <<'EOF'
if [ -x /usr/bin/lsd ]; then
alias lsd="/usr/bin/lsd"
# alias ls="lsd"
fi
EOF

View File

@ -3,7 +3,7 @@ mkdir -p ~/.config/vifm/scripts
# https://gitlab.com/dwt1/dotfiles/tree/master/.config/vifm/scripts
cat > ~/.zsh_aliases.d/005-vifm.zsh << 'EOF'
cat > ~/.zsh_aliases.d/005_vifm.zsh << 'EOF'
alias vifm="~/.config/vifm/scripts/vifmrun"
EOF

View File

@ -44,7 +44,7 @@ echo "NVIM_PYTHON_LOG_LEVEL=DEBUG" >> ~/.zshrc.d/008_nvim.zsh
touch /var/tmp/nvim_python.log
# Fix for using urls on the commandline
cat >> ~/.zshrc.d/005-url-quote-magic.zsh <<EOF
cat >> ~/.zshrc.d/005_url-quote-magic.zsh <<EOF
autoload -U url-quote-magic
zle -N self-insert url-quote-magic
@ -210,26 +210,26 @@ EOF
# example .d file use unset to prevent update
#echo '# Use unset 'QUICKSTART_KIT_REFRESH_IN_DAYS' to disable.' > ~/.zshrc.d/001-quickstart_refresh.zsh
#echo 'QUICKSTART_KIT_REFRESH_IN_DAYS=30' >> ~/.zshrc.d/001-quickstart_refresh.zsh
echo 'ZGEN_PLUGIN_UPDATE_DAYS=30' > ~/.zshrc.d/001-zgen_refresh.zsh
echo 'ZGEN_PLUGIN_UPDATE_DAYS=30' > ~/.zshrc.d/001_zgen-refresh.zsh
apt-get install -y fonts-powerline powerline
# sed -i 's,^\(export LOCATE_PATH=\).*,\1'/var/lib/mlocate/mlocate.db',' ~/.zshrc
# Use powerline-daemon to speedup the prompt.
echo 'powerline-daemon -q' > ~/.zshrc.d/006-powerline-daemon.zsh
echo 'powerline-daemon -q' > ~/.zshrc.d/006_powerline-daemon.zsh
sed -i 's,^\(CHARMAP=\).*,\1'\"UTF-8\"',' /etc/default/console-setup
# set theme for zsh
cat > ~/.zshrc.d/002-theme.zsh << 'EOF'
cat > ~/.zshrc.d/002_theme.zsh << 'EOF'
# https://zshthem.es/browse-zsh-themes/
ZSH_THEME="agnoster" # powerline based theme
#ZSH_THEME="3den"
#ZSH_THEME="Pure"
EOF
cat > ~/.zshrc.d/001-vi-mode.sh << 'EOF'
cat > ~/.zshrc.d/001_vi-mode.sh << 'EOF'
# Set vi mode
bindkey -v
bindkey '^R' history-incremental-search-backward
@ -254,117 +254,12 @@ EOF
#EOF
# alias python version
mkdir -p ~/.zsh_aliases.d
# tell bash to check the next word after the alias (i.e sudo) by adding a space to the end of the alias value.
echo "# tell bash to check the next word after the alias (i.e sudo) by adding a space to the end of the alias value." > ~/.zsh_aliases.d/002_sudo.zsh
echo 'alias sudo="sudo "' >> ~/.zsh_aliases.d/002_sudo.zsh
cat > ~/.zsh_aliases.d/003-py_aliases.zsh << 'EOF'
_py_version() {
PY_VERSIONS=(2 3)
LINE=(${(s: :)history[$HISTCMD]})
COMMAND=${LINE[1]}
ARGS=${(j: :)LINE[2,-1]}
while (( 1 )) {
read -s -k1 VERSION"?$COMMAND [${PY_VERSIONS[1]}]: "
if [[ $VERSION == $'\n' ]]; then
VERSION=${PY_VERSIONS[1]}
break
elif (( ${PY_VERSIONS[(I)$VERSION]} )); then
echo $VERSION
break
fi
echo "$VERSION is not supported (${(j:, :)PY_VERSIONS})"
}
if [[ -x $(which $COMMAND$VERSION) ]]; then
COMMAND=$COMMAND$VERSION
else
COMMAND="python$VERSION $(which -a $COMMAND | grep -v aliased | head -n 1)"
fi
eval $COMMAND $ARGS
}
# versioned python commands
alias python="_py_version"
alias pip="_py_version"
alias pydoc="_py_version"
alias idle="_py_version"
alias ipython="_py_version"
alias jupyter="_py_version"
EOF
cat > .zsh_aliases.d/003-transfer.zsh <<'EOF'
#
# Defines transfer alias and provides easy command line file and folder sharing.
#
# Authors:
# Remco Verhoef <remco@dutchcoders.io>
#
curl --version 2>&1 > /dev/null
if [ $? -ne 0 ]; then
echo "Could not find curl."
return 1
fi
transfer() {
# check arguments
if [ $# -eq 0 ];
then
echo -e "No arguments specified.\n\nUsage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"
return 1
fi
# get temporarily filename, output is written to this file show progress can be showed
tmpfile=$( mktemp -t transferXXX )
# upload stdin or file
file=$1
if tty -s;
then
basefile=$(basename "$file" | sed -e 's/[^a-zA-Z0-9._-]/-/g')
if [ ! -e $file ];
then
echo "File $file doesn't exists."
return 1
fi
if [ -d $file ];
then
# zip directory and transfer
zipfile=$( mktemp -t transferXXX.zip )
cd $(dirname $file) && zip -r -q - $(basename $file) >> $zipfile
curl --progress-bar --upload-file "$zipfile" "https://transfer.sh/$basefile.zip" >> $tmpfile
rm -f $zipfile
else
# transfer file
curl --progress-bar --upload-file "$file" "https://transfer.sh/$basefile" >> $tmpfile
fi
else
# transfer pipe
curl --progress-bar --upload-file "-" "https://transfer.sh/$file" >> $tmpfile
fi
# cat output link
cat $tmpfile
# log file link
APPLICATION="${0##*/}"
RIGHTNOW="$(date)"
EXPIRES="$(date -d "+14 days")"
echo -e "$(cat "$tmpfile") - uploaded $RIGHTNOW - expires $EXPIRES\n" >> ~/$APPLICATION.log
echo "\n\nSee ~/$APPLICATION.log for all transfers.\n"
# cleanup
rm -f $tmpfile
}
EOF
chown -R root.root /usr/local/share/zsh/site-functions

View File

@ -2,6 +2,8 @@
mkdir -p ~/.zsh_aliases.d
mkdir -p /home/default/.zsh_aliases.d
ALIAS_FILE=/home/default/.zsh_aliases
cat >> ${ALIAS_FILE} <<'EOF'
@ -11,6 +13,118 @@ if [ -d ~/.zsh_aliases.d ]; then
fi
EOF
# tell bash to check the next word after the alias (i.e sudo) by adding a space to the end of the alias value.
echo "# tell bash to check the next word after the alias (i.e sudo) by adding a space to the end of the alias value." > ~/.zsh_aliases.d/002_sudo.zsh
echo 'alias sudo="sudo "' >> ~/.zsh_aliases.d/002_sudo.zsh
cat > ~/.zsh_aliases.d/003_py-aliases.zsh << 'EOF'
_py_version() {
PY_VERSIONS=(2 3)
LINE=(${(s: :)history[$HISTCMD]})
COMMAND=${LINE[1]}
ARGS=${(j: :)LINE[2,-1]}
while (( 1 )) {
read -s -k1 VERSION"?$COMMAND [${PY_VERSIONS[1]}]: "
if [[ $VERSION == $'\n' ]]; then
VERSION=${PY_VERSIONS[1]}
break
elif (( ${PY_VERSIONS[(I)$VERSION]} )); then
echo $VERSION
break
fi
echo "$VERSION is not supported (${(j:, :)PY_VERSIONS})"
}
if [[ -x $(which $COMMAND$VERSION) ]]; then
COMMAND=$COMMAND$VERSION
else
COMMAND="python$VERSION $(which -a $COMMAND | grep -v aliased | head -n 1)"
fi
eval $COMMAND $ARGS
}
# versioned python commands
alias python="_py_version"
alias pip="_py_version"
alias pydoc="_py_version"
alias idle="_py_version"
alias ipython="_py_version"
alias jupyter="_py_version"
EOF
cat > .zsh_aliases.d/003_transfer.zsh <<'EOF'
#
# Defines transfer alias and provides easy command line file and folder sharing.
#
# Authors:
# Remco Verhoef <remco@dutchcoders.io>
#
curl --version 2>&1 > /dev/null
if [ $? -ne 0 ]; then
echo "Could not find curl."
return 1
fi
transfer() {
# check arguments
if [ $# -eq 0 ];
then
echo -e "No arguments specified.\n\nUsage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"
return 1
fi
# get temporarily filename, output is written to this file show progress can be showed
tmpfile=$( mktemp -t transferXXX )
# upload stdin or file
file=$1
if tty -s;
then
basefile=$(basename "$file" | sed -e 's/[^a-zA-Z0-9._-]/-/g')
if [ ! -e $file ];
then
echo "File $file doesn't exists."
return 1
fi
if [ -d $file ];
then
# zip directory and transfer
zipfile=$( mktemp -t transferXXX.zip )
cd $(dirname $file) && zip -r -q - $(basename $file) >> $zipfile
curl --progress-bar --upload-file "$zipfile" "https://transfer.sh/$basefile.zip" >> $tmpfile
rm -f $zipfile
else
# transfer file
curl --progress-bar --upload-file "$file" "https://transfer.sh/$basefile" >> $tmpfile
fi
else
# transfer pipe
curl --progress-bar --upload-file "-" "https://transfer.sh/$file" >> $tmpfile
fi
# cat output link
cat $tmpfile
# log file link
APPLICATION="${0##*/}"
RIGHTNOW="$(date)"
EXPIRES="$(date -d "+14 days")"
echo -e "$(cat "$tmpfile") - uploaded $RIGHTNOW - expires $EXPIRES\n" >> ~/$APPLICATION.log
echo "\n\nSee ~/$APPLICATION.log for all transfers.\n"
# cleanup
rm -f $tmpfile
}
EOF
ALIAS_FILE=/home/default/.zsh_aliases.d/003_local.sh
cat > ${ALIAS_FILE} <<'EOF'
alias locate='locate --existing --follow --basename --ignore-case'
@ -25,8 +139,10 @@ EOF
ALIAS_FILE=/home/default/.zsh_aliases.d/003_lsd.sh
cat > ${ALIAS_FILE} <<'EOF'
alias lsd="/usr/bin/lsd"
alias 'ls'="lsd"
alias 'll'="lsd -a"
alias 'lt'="lsd --tree"
if [ -x /usr/bin/lsd ]; then
alias lsd="/usr/bin/lsd"
alias 'ls'="lsd"
alias 'll'="lsd -a"
alias 'lt'="lsd --tree"
fi
EOF

View File

@ -48,7 +48,7 @@ touch /var/tmp/nvim_python.log
# debians locate db locate
# sed -i 's,^\(export LOCATE_PATH=\).*,\1'/var/lib/mlocate/mlocate.db',' ~/.zshrc
echo "export LOCATE_PATH=/var/lib/mlocate/mlocate.db" > ~/.zshrc.d/005-locatedb.zsh
echo "export LOCATE_PATH=/var/lib/mlocate/mlocate.db" > ~/.zshrc.d/005_locatedb.zsh
# add plugins to the load-starter-plugin-list() function in ~/.zgen-setup ~/zsh-quickstart-kit/zsh/.zgen-setup
# FIXED: create a file named .zgen-local-plugins and add your zgen load commands there.
@ -194,28 +194,28 @@ cat > ~/.zgen-local-plugins << 'EOF'
EOF
# example .d file use unset to prevent update
#echo '# Use unset 'QUICKSTART_KIT_REFRESH_IN_DAYS' to disable.' > ~/.zshrc.d/001-quickstart_refresh.zsh
#echo 'QUICKSTART_KIT_REFRESH_IN_DAYS=30' >> ~/.zshrc.d/001-quickstart_refresh.zsh
echo 'ZGEN_PLUGIN_UPDATE_DAYS=30' > ~/.zshrc.d/001-zgen_refresh.zsh
#echo '# Use unset 'QUICKSTART_KIT_REFRESH_IN_DAYS' to disable.' > ~/.zshrc.d/001_quickstart-refresh.zsh
#echo 'QUICKSTART_KIT_REFRESH_IN_DAYS=30' >> ~/.zshrc.d/001_quickstart-refresh.zsh
echo 'ZGEN_PLUGIN_UPDATE_DAYS=30' > ~/.zshrc.d/001_zgen-refresh.zsh
apt-get install -y fonts-powerline powerline
# sed -i 's,^\(export LOCATE_PATH=\).*,\1'/var/lib/mlocate/mlocate.db',' ~/.zshrc
# Use powerline-daemon to speedup the prompt.
echo 'powerline-daemon -q' > ~/.zshrc.d/006-powerline-daemon.zsh
echo 'powerline-daemon -q' > ~/.zshrc.d/006_powerline-daemon.zsh
sed -i 's,^\(CHARMAP=\).*,\1'\"UTF-8\"',' /etc/default/console-setup
# set theme for zsh
cat > ~/.zshrc.d/002-theme.zsh << 'EOF'
cat > ~/.zshrc.d/002_theme.zsh << 'EOF'
# https://zshthem.es/browse-zsh-themes/
ZSH_THEME="agnoster" # powerline based theme
#ZSH_THEME="3den"
#ZSH_THEME="Pure"
EOF
cat > ~/.zshrc.d/001-vi-mode.sh << 'EOF'
cat > ~/.zshrc.d/001_vi-mode.sh << 'EOF'
# Set vi mode
bindkey -v
bindkey '^R' history-incremental-search-backward
@ -283,7 +283,7 @@ alias ipython="_py_version"
alias jupyter="_py_version"
EOF
cat > .zsh_aliases.d/003-transfer.zsh <<'EOF'
cat > .zsh_aliases.d/003_transfer.zsh <<'EOF'
#
# Defines transfer alias and provides easy command line file and folder sharing.
#