GithubHelp home page GithubHelp logo

scripts-28's Introduction

Scripts

This is a collection of all my shell and batch scripts.

 

Introduction

Executable

Define, how the file should be interpreted.

#!/bin/sh
#!/bin/bash

 

To restart Finder, in order to activate new settings use the following:

killall Finder

 

If- Else Statements are done like this.

if [condition]
then
(… do something here)
else
(… do something here)
fi

 

Loops and those stuff.

for variable in defined_variable
do
(… do something here)
done

 

Create and delete Folders. Just like God.

Create:

mkdir path/to/folder/name_of_folder

Delete:

rmdir path/to/folder/name_of_folder

 

Stress test your MAC:

yes

To cancel press Ctrl-C

 

This makes the file executable on doubleclick:

chmod a+x file.sh

 

Programs

Description of all Programs.  

run_evonHome

This is for my current project, which acts as a degree dissertation.

cd /Users/PeterBrain/Desktop/evonHOME
node System/plc.js

 

ShowHiddenFiles

I’m too tired of typing this line into the command-line-tool, so I’ve done this. Explanation: Make files, which are usually invisible to us, visible. Restart of Finder is necessary.

defaults write com.apple.finder AppleShowAllFiles YES

 

HideHiddenFiles

To reverse the effect of "ShowHiddenFiles". Better: Make actual invisible files invisible. Restart of Finder is necessary.

defaults write com.apple.finder AppleShowAllFiles NO

 

ToggleHiddenFiles

To toggle it is necessary to know the current setting.

status=`defaults read com.apple.finder AppleShowAllFiles`

 

mount/unmount smb Network Drive

Aliases of Network Drives do the same thing, but need more space on desktop and it’s much cooler to do it that way.

This part of the code retrieves the SSID of the connected wireless network.

SSID=$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk -F': ' '/ SSID/ {print $2}')

 

Exploding strings is often very important and useful (IFS for later research): array=(${variable//delimiter/})

How to use the created array: ${array[0]}

 

Mount a smb network drive:

mount -t smbfs smb://user@server/share /path/to/temporary/shared_folder

Unmount a smb network drive:

umount -t smbfs /path/to/temporary/shared_folder

I recommend using this path: /tmp/share/name_of_share

 

mount/unmount USB Drive

Diskutil is the one keyword.

diskutil list
diskutil mount [DiskIdentifier|DeviceNode]
diskutil unmount [DiskIdentifier|DeviceNode]

When using the USB Drives name, you have to quote it. DeviceNode expample: /dev/disk1s1

 

Turn internal keyboard on/off

To turn the keyboard on or off you have to unload or load a .kext file.

This one disables it:

kextunload -b com.apple.driver.AppleUSBTCKeyboard

And this one enables it:

kextload -b com.apple.driver.AppleUSBTCKeyboard

!Attention! Maybe you have to use an external Keyboard to re-enable it.

Long Version with real Paths:

sudo kextunload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/ || sudo kextload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/

 

Create a blank icon on dock

This feature is good to separate applications from each other.

This is all the magic:

defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}'

killall Dock

The blank space stays after a reboot, so you have to run it only once.  

scripts-28's People

Contributors

peterbrain avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.