Skip to content

Commit

Permalink
Fixing functions and aliases for Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
TimTr committed Apr 22, 2024
1 parent 9542210 commit 8a508d9
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 56 deletions.
81 changes: 81 additions & 0 deletions Linux/dot-aliases.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# source this file into .zshrc

if [[ -v LOADED_ALIAS ]]; then return; fi
LOADED_ALIAS=true


# ===========================================
# Aliases

# ... Turn off the Quarantine Bit for all files in local folder
alias qbit="xattr -d com.apple.quarantine ./*"

# ... Eject a volume (type the volume name after)
alias eject="hdiutil detach -verbose -force /Volumes/"

# ... Touch the time and date recursively for all files in current folder
alias touchall="find . -exec touch {} \;"

# ... Tell Time Machine to use higher CPU priority until reboot
alias time-machine-fast="sudo sysctl debug.lowpri_throttle_enabled=0"

# launch the iOS Simulator app from the command line
# you can then type "simulator help" or "simulator list" to see more info
alias simulator="xcrun simctl"

# Recursively remove .DS_Store files
alias cleanupds="find . -type f -name '*.DS_Store' -ls -delete"

# Easier navigation: .., ..., ~ and -
alias ..="cd .."
alias cd..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."

# alias reload!='. ~/.zshrc'

# mv, rm, cp
alias mv='mv -v'
alias rm='rm -i -v'
alias cp='cp -v'

# Use the eza command by default, if installed (better ls)
if ! command -v eza &> /dev/null
then
echo "Tool \`eza\` not found. For a better \`ls\` run: brew install eza"
# Use 'll' to suppress the "show all" flag when listing files
alias ll='ls -oFGT'
# Use 'lla' to enable "show all" for hidden files beginning with a period
alias lla='ls -oAFGT'
# Use 'llx' to see the most info, including extended attributes
alias llx='ls -o@AFGT'
# Use 'llt' to see the files sorted by modification time
alias llt='ls -otAFGT'
# Make standard 'ls' look prettier, with colors and sorting
# alias ls='ls -FG'
else
echo "Aliasing \`ll\` and other \`ls\` commands to use \`eza\`"

alias ll='eza --long --sort=Name --git --git-repos -I "Icon?" --group-directories-first --no-quotes --no-permissions --no-user'
alias lla='eza -a --long --sort=Name --git -I "Icon?" -I ".DS_Store" --group-directories-first'
alias llx='eza -a --long --sort=Name --git -I "Icon?" -I ".DS_Store" --group-directories-first -@ -Z'
alias llt='eza --tree'
fi


# Git can sometimes create locked files in the .git folder, which then
# blocks things like compress tasks, or copying files. Run "unlock" to
# unlock all files in the current folder (and recursively)
alias showlocks="find . -flags +uchg"

alias unlock="find . -flags +uchg -exec chflags nouchg {} \;"

# ... echo $SHELL tells you the default shell, this command
# instead tells you which shell you are presently inside
alias shell-now='ps -p $$'

# original color-coded lsl command: alias lsl='ls -loFGT'
# sorts folders at the top: ls -la | grep "^d" && ls -la | grep -v "^d"
# NOTE: if you sort you lose the LS coloring in the output (sad face)

69 changes: 16 additions & 53 deletions Linux/dot-functions.sh
Original file line number Diff line number Diff line change
@@ -1,68 +1,31 @@
# source this file into .zshrc
#!/bin/zsh

if [[ -v LOADED_FUNCTIONS ]]; then return; fi
LOADED_FUNCTIONS=true


# Functions to make output attractive when running the script
#
# NOTE: some characters in parameters will not work, e.g. "!"
#

# `message` and `error` take two string parameters
message () { printf "\r [\033[00;32m $1\033[0m ] $2\n" }
error () { printf "\r\033[00;31m ** $1\033[0m - \033[00;31m$2 \033[0m \n" }
alert () { printf "\r\033[00;35m >> $1\033[0m $2\n" }
bullet () { printf "\r\033[00;36m ==\033[0m $1 $2\n" }

# `alert` and `bullet` take one parameter
alert () { printf "\r\033[00;35m >> $1\033[0m \n" }
bullet () { printf "\r\033[00;36m ==\033[0m $1\n" }


# Function to find all files recursively under current folder
# ... Find all files recursively under current folder
findall () {
find ./ -name $1 -print 2> /dev/null
}

# Function to create a new directory and enter it
# ... Create a new directory and enter it
md() {
mkdir -p "$@" && cd "$@"
mkdir -p "$@" && cd "$@"
}

# ===========================================
# Aliases

# Easier navigation: .., ..., ~ and -
alias ..="cd .."
alias cd..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."

alias reload!='. ~/.zshrc'

# mv, rm, cp
alias mv='mv -v'
alias rm='rm -i -v'
alias cp='cp -v'

# ... Make 'ls' look a lot prettier
alias ls='ls -FG'
alias lsl='ls -loFGT'
alias lsla='ls -loAFGT'

# ... echo $SHELL tells you the default shell, this command
# instead tells you which shell you are presently inside
alias shell-now='ps -p $$'

# original color-coded lsl command: alias lsl='ls -loFGT'
# sorts folders at the top: ls -la | grep "^d" && ls -la | grep -v "^d"
# NOTE: if you sort you lose the LS coloring in the output (sad face)


# ... Turn off the Quarantine Bit for all files in local folder
alias qbit="xattr -d com.apple.quarantine ./*"

# ... Eject a volume (type the volume name after)
alias eject="hdiutil detach -verbose -force /Volumes/"

# ... Touch the time and date recursively for all files in current folder
alias touchall="find . -exec touch {} \;"

# ... Tell Time Machine to use higher CPU priority until reboot
alias time-machine-fast="sudo sysctl debug.lowpri_throttle_enabled=0"
# Delete Xcode derived data
xcode-clean() {
echo "Deleting all Xcode derived data..."
rm -rdf ~/Library/Developer/Xcode/DerivedData/*
}

3 changes: 2 additions & 1 deletion Linux/dotfiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ cp $DOTFILES_ROOT/Linux/dot-zshenv.sh $HOME/.zshenv
cp $DOTFILES_ROOT/Linux/dot-aliases.sh $HOME/.aliases
cp $DOTFILES_ROOT/Linux/dot-functions.sh $HOME/.functions

# Register gitignore and other git stuff
# Copy over tool and app settings
cp $DOTFILES_ROOT/Config/dot-gitconfig $HOME/.gitconfig
cp $DOTFILES_ROOT/Config/dot-gitignore $HOME/.gitignore
cp $DOTFILES_ROOT/Config/dot-vimrc $HOME/.vimrc

# Register gitignore and other git stuff
git config --global core.excludesfile ~/.gitignore


Expand Down
6 changes: 4 additions & 2 deletions dotfiles.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
BABDAC482BC1ED2100DA5858 /* index.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = index.md; sourceTree = "<group>"; };
BABDAC492BC1ED2100DA5858 /* overview.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = overview.md; sourceTree = "<group>"; };
BABDAC4A2BC1ED2100DA5858 /* todo.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = todo.md; sourceTree = "<group>"; };
BABDAC4C2BC1ED4700DA5858 /* dot-functions.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "dot-functions.sh"; sourceTree = "<group>"; };
BABDAC4D2BC1ED4700DA5858 /* dot-zshenv.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "dot-zshenv.sh"; sourceTree = "<group>"; };
BABDAC4E2BC1ED4700DA5858 /* dotfiles.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = dotfiles.sh; sourceTree = "<group>"; };
BABDAC4F2BC1ED4700DA5858 /* dot-zshrc.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "dot-zshrc.sh"; sourceTree = "<group>"; };
BAD8D5C82BD6F41400E0077F /* dot-aliases.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "dot-aliases.sh"; sourceTree = "<group>"; };
BAF585262BD6F45100A2E7F1 /* dot-functions.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "dot-functions.sh"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXGroup section */
Expand Down Expand Up @@ -114,7 +115,8 @@
BABDAC4B2BC1ED3C00DA5858 /* Linux */ = {
isa = PBXGroup;
children = (
BABDAC4C2BC1ED4700DA5858 /* dot-functions.sh */,
BAF585262BD6F45100A2E7F1 /* dot-functions.sh */,
BAD8D5C82BD6F41400E0077F /* dot-aliases.sh */,
BABDAC4D2BC1ED4700DA5858 /* dot-zshenv.sh */,
BABDAC4F2BC1ED4700DA5858 /* dot-zshrc.sh */,
BABDAC4E2BC1ED4700DA5858 /* dotfiles.sh */,
Expand Down

0 comments on commit 8a508d9

Please sign in to comment.