4 ms·
I'd add how I load a terminal enviroment for different profiles. In .zshrc I have the least possible things so it opens fast. But I include the commands that w
by sebastianconcpt 4y ago
I'd add how I load a terminal enviroment for different profiles.
In .zshrc I have the least possible things so it opens fast. But I include the commands that would extend (srcBlah) or help me tune how to extend (editBlah):
For my pet projects I'd use these two:
alias editSeb="code ~/.sebrc"
alias srcSeb="source ~/.sebrc"
As you can see, editSet opens VSCode and src is sourcing it in the current terminal.
.sebrc
# Download video from the given YouTube URL
function ytdl() {
youtube-dl -x --audio-format mp3 --prefer-ffmpeg $1
}
# Download audio from the given YouTube URL
function ytmp3() {
ytdl $1 | ffmpeg -i pipe:0 -b:a 320K -vn $2.mp3
}
# Shows total size of the given directory at $1
function dus() {
du -h -d 1 $1
}
# Used to opt-out of pre-commit autofixes
export NO_COMMIT_CHECKS=true
function cleanUSB() {
volumeName=$1
subdir=$2
if [[ "$volumeName" != "" ]] && [[ "$subdir" = "" ]]; then
rm -rfv /Volumes/$volumeName/.DS_Store
rm -rfv /Volumes/$volumeName/.Spotlight-V100
rm -rfv /Volumes/$volumeName/.fseventsd
rm -rfv /Volumes/$volumeName/.Trashes
rm -rfv /Volumes/$volumeName/._\*
echo "Volume $volumeName is clean"
elif [[ "$volumeName" != "" ]] && [[ "$subdir" != "" ]]; then
rm -rfv /Volumes/$volumeName/$subdir/.DS_Store
rm -rfv /Volumes/$volumeName/$subdir/.Spotlight-V100
rm -rfv /Volumes/$volumeName/$subdir/.fseventsd
rm -rfv /Volumes/$volumeName/$subdir/.Trashes
rm -rfv /Volumes/$volumeName/$subdir/._\*
echo "Volume $volumeName/$subdir is clean"
else
echo "No volume name given. Nothing to do."
fi
}
function blogBackup() {
rsync -avzh --progress -e ssh root@seb-nyc1-01:/root/blog/db /Users/seb/Documents/blog
}
alias showHiddenFiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app'
alias hideHiddenFiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app'
# Show ports currently listening
function openPorts() {
netstat -p tcp -van | grep '^Proto\|LISTEN'
}
# Create a RAM disk on macOS
function ramDisk() {
# https://eshop.macsales.com/blog/46348-how-to-create-and-use-a-ram-disk-with-your-mac-warnings-included/
# 2048 = 1MB
# 2097152 = 1G
quantityOfBlocks=2097152
diskutil erasevolume HFS+ "RAMDisk" `hdiutil attach -nomount ram://${quantityOfBlocks}`
}
# Tauri watcher for source file changes will not stop automatically.
function killRollup() {
ps aux | grep node | grep rollup | awk '{print $2;}' | xargs kill -9 $1
}
# X pet project required env var
export X_TOKEN=blahValue
function dockerCleanAll() {
docker stop $(docker ps -aq)
docker rm $(docker ps -aq)
docker rmi $(docker images -q) -f
}
function dockerCleanVolumes() {
docker volume rm $(docker volume ls -qf dangling=true)
}
alias ll='ls -lah'
alias gg='git status -s'
# Creates a timestamped backup of the current branch:
alias gbk='git checkout -b "backup-$(git symbolic-ref -q HEAD --short)-$(date +%Y-%m-%d-%H.%M.%S)" && git checkout -'