mirror of
https://codeberg.org/vlw/dotfiles.git
synced 2025-09-13 19:03:40 +02:00
66 lines
1.5 KiB
Bash
66 lines
1.5 KiB
Bash
# Make dir and cd into it
|
|
mkcdir () {
|
|
mkdir -p -- "$1" && cd -P -- "$1"
|
|
}
|
|
|
|
# Preview contents of a file or list the contents of a directory
|
|
l () {
|
|
if [ -f "$1" ] ; then
|
|
less $1
|
|
return
|
|
fi
|
|
|
|
ls -lh $1 || l $(dirname "$1")
|
|
}
|
|
|
|
# Preview the contents of a file or list the contents of a directory with hidden files shown
|
|
ll () {
|
|
if [ -f "$1" ] ; then
|
|
less $1
|
|
return
|
|
fi
|
|
|
|
ls -lah $1 || ll $(dirname "$1")
|
|
}
|
|
|
|
# Edit the contents of a file or list the contents of a directory (with hidden files shown) if that file is not found
|
|
lll () {
|
|
if [ -f "$1" ] ; then
|
|
nano $1
|
|
return
|
|
fi
|
|
|
|
ls -lah $1 || lll $(dirname "$1")
|
|
}
|
|
|
|
.. () {
|
|
cd .. && l
|
|
}
|
|
|
|
cdl () {
|
|
cd -P -- "$1" && l
|
|
}
|
|
|
|
cdll () {
|
|
cp -P -- "$1" && ll
|
|
}
|
|
|
|
# Create standard git WIP commit with timestamps
|
|
alias gitw="git commit -m \"wip: $(date +%Y-%m-%dT%H:%M:%S%z) ($(date +%s))\""
|
|
# Create a git WIP tag with the current timestamp. Prompt user for tag comment.
|
|
alias gitt="git tag -a 'wip-$(date +%s)'"
|
|
# Remove dropped upstream git branches from remote
|
|
alias gitc="git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D"
|
|
# Shorthand git pull origin
|
|
alias gitp="git pull origin"
|
|
# Shorthand git status"
|
|
alias gits="git status"
|
|
|
|
# Generate random 16byte HEX
|
|
alias rng16="head -c 16 /dev/random | xxd -p"
|
|
|
|
# Kill VSCode processes
|
|
alias killvscode="ps uxa | grep .vscode-server | awk '{print $2}' | xargs kill -9"
|
|
|
|
# Change PHP CLI binary
|
|
alias chphp="sudo update-alternatives --config php"
|